Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 134440

MultiformeIngegno on "get_posts output always same post"

$
0
0

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 all articles
Browse latest Browse all 134440

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>