372 posts
  • Has been part of the Envato Community for over 5 years
  • Has sold $1,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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
  • Has been part of the Envato Community for over 6 years
  • Has referred 50+ members
  • Has sold $10,000+ on Envato Market
  • Had an item featured in an Envato Bundle
+6 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
  • Has been part of the Envato Community for over 5 years
  • Has sold $1,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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
  • Has been part of the Envato Community for over 5 years
  • Has sold $1,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
mrjasmin says

Problem solved..

28 posts
  • Has referred 1+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+4 more
sebrosen says

mrjasmin, could you explain how you solved it? thanks

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by