WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Custom Loop (4 posts)

  1. arav369
    Member
    Posted 1 year ago #

    I have to create a loop of the top 5 posts falling under any 1 or more of a set of categories. I have browsed the support forums and tried out all combinations. It is not working for me.

    One odd output I got was that posts 2,4,6,8,10 that were falling under any 1 or more of the set of categories were displayed. Instead of the top 5 posts (1,2,3,4,5). The loop was skipping every alternate post.The code I used was as follows:

    query_posts('category_name=cat1,cat2');
    $ctr=1; while (have_posts() && $ctr<6) : the_post(); { $ctr++ ?>
    ---
    ---
    }?>

    Please provide the code for achieving this custom loop.

    Thanks in advance.

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

  3. deepbevel
    Member
    Posted 1 year ago #

    I spent an hour with this last night, checked Sweepers references and more...stumped. Sorry I don't remember the codes I tried but I felt I wasn't even close, gettting no output.

    I've always wanted to do this too, tried before and gave up. I've always had to use multiple loops..

  4. deepbevel
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic