Title: get_posts output always same post
Last modified: August 21, 2016

---

# get_posts output always same post

 *  [multiformeingegno](https://wordpress.org/support/users/lorenzone92/)
 * (@lorenzone92)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/get_posts-output-always-same-post/)
 * I’m trying to output the last (chronologically) 4 posts having the tag (slug)“
   pp”.
 *     ```
       <ul>
           <?php
           $args = array( 'posts_per_page' => 4, 'taxonomy' => 'tag', 'field' => 'slug', 'terms' => 'pp' );
           $tag_posts = get_posts( $args );
           foreach ( $tag_posts as $post ) :
             setup_postdata( $post ); ?>
           	<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
           <?php endforeach;
           wp_reset_postdata(); ?>
           </ul>
       ```
   
 * This snippet though output 4 entries of the same post, which is the fourth from
   last! How come? 🙂

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/get_posts-output-always-same-post/#post-4366830)
 * Try it with a tax_query:
 *     ```
       $args = array(
           'posts_per_page' => 4,
           'tax_query'      => array(
               array(
                   'taxonomy' => 'post_tag',
                   'field'    => 'slug',
                   'terms'    => 'pp'
               )
           )
       );
       $tag_posts = get_posts( $args );
       ```
   
 * [http://codex.wordpress.org/Function_Reference/WP_Query#Taxonomy_Parameters](http://codex.wordpress.org/Function_Reference/WP_Query#Taxonomy_Parameters)
 *  Thread Starter [multiformeingegno](https://wordpress.org/support/users/lorenzone92/)
 * (@lorenzone92)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/get_posts-output-always-same-post/#post-4366832)
 * Thanks for the reply 🙂
    Now I get 4 links to the home page..
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/get_posts-output-always-same-post/#post-4366838)
 * Are the titles of the links correct?
 *  Thread Starter [multiformeingegno](https://wordpress.org/support/users/lorenzone92/)
 * (@lorenzone92)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/get_posts-output-always-same-post/#post-4366840)
 * Yep, they are 4 links to the home page with as title the page I use as home page.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/get_posts-output-always-same-post/#post-4366843)
 * Try:
 * – deactivating **all** plugins to see if this resolves the problem? If this works,
   re-activate the plugins one by one until you find the problematic plugin(s).

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘get_posts output always same post’ is closed to new replies.

## Tags

 * [get_posts](https://wordpress.org/support/topic-tag/get_posts/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)
 * [tags](https://wordpress.org/support/topic-tag/tags/)
 * [taxonomy](https://wordpress.org/support/topic-tag/taxonomy/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * Last activity: [12 years, 5 months ago](https://wordpress.org/support/topic/get_posts-output-always-same-post/#post-4366843)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
