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)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘get_posts output always same post’ is closed to new replies.