WordPress.org

Support

Support » Plugins and Hacks » [Resolved] get_posts not working properly

[Resolved] get_posts not working properly

  • This snippet inside a PHP code widget returns 7 links to the same post.
    Outside the widget (directly executed for example in a custom template), works properly and returns 7 different posts:

    <ul>
    <?php
    $args = array( 'posts_per_page' => 7, 'category' => 9 );
    $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>

    http://wordpress.org/plugins/php-code-widget/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] get_posts not working properly’ is closed to new replies.