WordPress.org

Ready to get started?Download WordPress

Forums

controlling loop post count (5 posts)

  1. zaphod22
    Member
    Posted 7 years ago #

    On my blog, I have a series of conditionals. Each conditional has a slightly different output as each is for different categories of posts.

    One thing that I have noticed is that if a category isn't displayed because of my conditionals in the loop, wordpress still counts it as being diplayed, and sometimes only shows 7 posts (when there should be 10).

    Is there a way to control the number of posts that wordpress *thinks* it has displayed?

    (what I am aiming to do is lower the post count by one to account for the post not shown)

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    No. It doesn't work that way.

    Basically, you're going to the database and telling it to give you the most recent 10 posts. This happens before the Loop ever starts. If you don't display some of those posts, then you don't have any easy way to tell WordPress to go fetch more of them.

    If you want to exclude categories entirely from your Loop without affecting the count, then you have to do it in the initial query. The Category Visibility plugin does this sort of thing: http://ryowebsite.com/?p=46

  3. zaphod22
    Member
    Posted 7 years ago #

    Ok. The site says that plugin does not work in 2.1

    Is there any other way to compensate for this problem, but still be able to use the loop for those categories when needed?

  4. Chris_K
    Member
    Posted 7 years ago #

    Go back to that link and read closer. Isn't there a 2.1 beta version listed?

    Or, have a look at Ultimate Category Excluder plugin

  5. joel01
    Member
    Posted 6 years ago #

    I'd like to know how to do this without a plugin. The Loop entry in the codex says the following about excluding categories in The Loop:

    Please note that even though the post is not being displayed it is still being counted by WordPress as having been shown -- this means that if you have WordPress set to show at most seven posts and that two of the last seven are from Category 3 then you will only display five posts on your main page. If this is a problem for you, there is more complicated hack you can employ described in the Layout and Design FAQ or you can use query_posts if you only need to exclude one category from the loop.

    However, the Layout and Design FAQ doesn't seem to mention this complicated hack. Would anyone know what it involves?

Topic Closed

This topic has been closed to new replies.

About this Topic