Answers for "wp add shortcode for custom post type"

PHP
0

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' );
Posted by: Guest on July-03-2021
0

how to grab shortcode from custom post type

<?php apply_filters('the_content',get_the_content( $more_link_text, 
 $stripteaser, $more_file )) ?>
Posted by: Guest on November-21-2020

Code answers related to "wp add shortcode for custom post type"

Browse Popular Code Answers by Language