Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other WordPress – query_posts issue

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #39017
    Chasew
    Participant

    I’m trying to display a list of recent posts from a specific category. I’ve been scouring all over the interweb looking for solutions, and everything I try only works half way.

    No matter what I do, the resulting list displays 6 posts, regardless of what I set it to. Both of the following seem to work, yet they both return 6 posts. At first I thought I must be missing something, but after trying countless different options, and noticing that it’s always 6 posts, I’m thinking there’s something else at work. Any ideas?



    $recentposts = get_posts('numberposts=3&category_name=portfolio');
    foreach ($recentposts as $post) :
    setup_postdata($post); ?>
  • ">

  • #106593
    TheDoc
    Member

    In the first query_posts there should be no spaces after ‘portfolio’.

    Also, you should be clearing your query_posts with:

    #106595
    Chasew
    Participant

    I noticed the blank space as well but figured that wasn’t the problem (at this point my priority is to just get it working).

    I’m also very rusty right now, but I don’t remember having such issues with simple things like this.

    Is this more proper?

    Still doesn’t work. There’s 4 posts in that category and all 4 are listed rather than 3

    #106599
    krang
    Member

    Try showposts=3 rather than posts_per_page=3

    #106602
    Chasew
    Participant

    PERFECT! That seems to do the trick.

    Thanks for the help to both of you!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Other’ is closed to new topics and replies.