Support » Fixing WordPress » excluded categories in home.php but published posts are counted towards total
excluded categories in home.php but published posts are counted towards total
-
Hi, I’m struggling with the following:
I made a site with a home.php template and I am listing only the excerpts there of the posts.
I have also excluded 2 categories and I publish those separately with 2 different templates.
But on the homepage after a mere 6 published posts (total of 12) the page navigation already shows up.
Is there a way to exclude the posts from the excluded categories also for the published-post-count in the navigation?
website is winesofvalencia.com
-
What are you using to exclude the categories in the Loop? get_posts or query_posts?
hi esmi, thanks for your quick response.
I’m using neither…
What I am using is
<?php if (in_category(array('7','13'))) continue; ?>
where cat 7 and 13 are the excluded ones…
In that case, that’s where the problem is. You’d be better of using query_posts to construct a custom query along the lines of:
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args= array( 'category__not_in' => array(7,13), 'paged' => $paged ); query_posts($args); ?>
cool, thanks i will try that and let you know how it goes
works brilliantly!
thanks a lot for the solution and the speed!
sorry esmi, i guess i celebrated too early.
as you can see on the site, it is not working at all as page navigation is completely broken now.
problems now are:
1) second page never shows up
2) post(s) of excluded category are
a) counted towards the total
b) showing up in the listI remember I had this problem before and that is why I came up (after some search) with
<?php if (in_category(array('7','13'))) continue; ?>
is there a solution that works?
That should work. It’s lifted straight from the relevant Codex page with the added fix in to handle paging. Are you using a page navigation plugin? I wonder if that is causing a problem?
yeah i’m using the famous PageNavi by Lester Chan, I will first disable that and try to get it working first without.
Loads of people have the same problem and all he does is referring to the codex: Template_Tags/query_posts
Could be an idea for him to write “The definite Tutorial on PageNavi”…
yeah sorry for that, all is working perfect.
I forgot to reset the query, so that messed it all up. Again sorry for that and thanks for the responses!
- The topic ‘excluded categories in home.php but published posts are counted towards total’ is closed to new replies.