372 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Sold between 1 000 and 5 000 dollars
  • Sweden
mrjasmin says

Hi ! I have a small problem when trying to exclude one category in my WP-loop. My blog shows 5 posts as standard and when I exclude one category than it show only 3 posts and the pagination.

The problem is that is should show 5 posts and the pagination because i have more than 15 posts in the not-excluded categories.

I hope that you understand what I mean. This is the code I use in the loop.

http://pastie.org/512431

Thanks

352 posts
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 50 and 99 users
  • Sold between 10 000 and 50 000 dollars
+1 more
danharper says

This is because when you use:


<?php if (in_category('portfolio')) continue; ?>

“even though the post [in the portfolio category] 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 [the portfolio category] then you will only display five posts on your main page”.
(via The Loop – WordPress Codex)

Use this code instead.
Change the ‘5’ in query_posts to the ID of the category you want to exclude – you can’t type the name.

(Make sure you keep the minus/hyphen (”-”) in paged=$paged&cat=-5 as it tells WordPress to exclude that category.

372 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Sold between 1 000 and 5 000 dollars
  • Sweden
mrjasmin says
This is because when you use:

<?php if (in_category('portfolio')) continue; ?>

“even though the post [in the portfolio category] 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 [the portfolio category] then you will only display five posts on your main page”.
(via The Loop – WordPress Codex)

Use this code instead.
Change the ‘5’ in query_posts to the ID of the category you want to exclude – you can’t type the name.

(Make sure you keep the minus/hyphen (”-”) in paged=$paged&cat=-5 as it tells WordPress to exclude that category.

Okey. Thanks for taking the time to help me. The reason that I want to use category name instead of ID is because this is a wordpress theme that I´m making for TF and if I use ID than the buyer must change the ID.

372 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Sold between 1 000 and 5 000 dollars
  • Sweden
mrjasmin says

Problem solved..

28 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Denmark
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • Bought between 50 and 99 items
sebrosen says

mrjasmin, could you explain how you solved it? thanks

by
by
by
by
by
by