Show the posts that were tagged with a some keywords

wordpress show posts with certain tag

WordPress tutorial, wordpress show posts with certain tag. We can show the five posts with certain tags. We can use following code for showing the posts.

wordpress show posts with certain tag

Just use the following code. Copy paste in to template page where you want to show posts.

<?php
$args = array( 'numberposts' => 5, 'order'=> 'DESC', 'orderby' => 'post_date', 'tag_slug__in' => array( 'wordpress, tag1,tag2' ) );
$postslist = get_posts( $args ); foreach ($postslist as $post) : setup_postdata($post); ?>
 <?php the_time('F j, Y'); ?>
<a href="<?php echo get_permalink(); ?>">
<?php the_title(); ?>
 </a> <?php the_excerpt(); ?>
 <?php endforeach; ?>
wordpress show posts with certain tag
wordpress show posts with certain tag

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.