wp add shortcode for custom post type
function diwp_create_shortcode_movies_post_type(){
$args = array(
'post_type' => 'movies',
'posts_per_page' => '10',
'publish_status' => 'published',
);
$query = new WP_Query($args);
if($query->have_posts()) :
while($query->have_posts()) :
$query->the_post() ;
$result .= '<div class="movie-item">';
$result .= '<div class="movie-poster">' . get_the_post_thumbnail() . '</div>';
$result .= '<div class="movie-name">' . get_the_title() . '</div>';
$result .= '<div class="movie-desc">' . get_the_content() . '</div>';
$result .= '</div>';
endwhile;
wp_reset_postdata();
endif;
return $result;
}
add_shortcode( 'movies-list', 'diwp_create_shortcode_movies_post_type' );