Answers for "shortcode new post wordpress"

PHP
2

do shortcode wordpress

<?php echo do_shortcode('[name_of_shortcode]'); ?>
Posted by: Guest on December-26-2020
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

Code answers related to "shortcode new post wordpress"

Browse Popular Code Answers by Language