WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


<?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>



share|improve this question

migrated from stackoverflow.com Apr 18 '12 at 16:04

This question came from our site for professional and enthusiast programmers.

up vote 2 down vote accepted

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')

String version for your case:

share|improve this answer
Thanks for your help but I cannot get it to work. I am using this code: <?php $args = array( 'category__in' => array(4), 'posts_per_page' => 4, 'tag' => array('Bolivia', 'Brazil') ) ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="list-box"> <a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail($args, array(120, 100)); ?></a> <div class="list-box-title"><h3><?php the_title(); ?></h3></div> </div> <?php endwhile; endif; wp_reset_query(); ?> ?> – rt840 Apr 15 '12 at 15:36
What's the error? Also have you tried the string version? – HappyTimeGopher Apr 15 '12 at 16:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.