Loop with excluded category not working properly
-
Hi all, this is my first post so please forgive me if it’s not in the right place or if the answer has already been given (i’ve made some research but didn’t find anything on it). Here we go !
I’m currently working on my personal website. I’m a composer and my website will feature a work page as well as a blog. Works are posts in “Work” category and blog posts are in “Blog” category or a child of it.
On index.php, archive.php, category.php, search.php, i use exactly the same code, but the results are not same ! Here is my (simplified) loop :
<?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <?php if (in_category('work')) continue; ?> <?php the_title(); ?> <?php the_content(); ?> <?php previous_posts_link('« Newer Entries') ?> <?php next_posts_link('Older Entries »') ?> <?php else : ?> <p>Sorry, but you are looking for something that isn't here.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?>
The <?php if (in_category(‘work’)) continue; ?> line is because i do not want works to show up on any page of the blog.
On archive.php, category.php and search.php, everything works just fine. I have 10 blog posts showing with adequate previous posts link. (we’re on page 1)
On index.php (blog home), i only have 6 blog posts showing with previous posts link. The thing is i have 11 matching blog posts, so the page should show up 10 blog posts. The interresting fact is that within the 10 last posts (incuding works), there are … 4 works.The loop is behaving as it was not showing work posts but count it anyway, which does not occur on other pages !
Does someone have an idea on how to solve this ?
Is this a bug ?Thank you very much !
- The topic ‘Loop with excluded category not working properly’ is closed to new replies.