Display posts and thumbnails with certain tags

I want to display specific posts from an array with specific tags i.e. “Bolivia” and “Brazil” and then show the post thumbnail and permalink.

This is the code I am using so far but as you can see I am not calling the tags.

Read More

Thanks.

<?php query_posts(array('category__in' => array(4), 'posts_per_page' => 4)); ?>

        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

              <?php $currentid = get_the_id(); ?>

              <div class="list-box">

                <a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail($currentid, array(120, 100)); ?></a>

                 <div class="list-box-title"><h3><?php the_title(); ?></h3></div>

               </div>

              <?php
           endwhile;
       endif;

  wp_reset_query();
 ?>

Related posts

Leave a Reply

1 comment

  1. See the WP docs for query_posts.

    Relevant excerpt:

    The following returns all posts that belong to category 1 and are tagged "apples"
    
        query_posts( 'cat=1&tag=apples' );
    
    You can search for several tags using +
    
        query_posts( 'cat=1&tag=apples+apples' );
    

    Or using the array version you’re using, something like this:

    $args = array(
        'category__in' => array(4),
        'posts_per_page' => 4,
        'tag' => array('Bolivia', 'Brazil')
    )
    query_posts($args);
    

    String version for your case:

    query_posts('category__in=4&posts_per_page=4&tag=Bolivia,Brazil');