- Author had a File in an Envato Bundle
- Author was Featured
- Bought between 500 and 999 items
- Exclusive Author
- Has been a member for 4-5 years
- Interviewed on the Envato Notes blog
- Netherlands
- Referred between 50 and 99 users
- Repeatedly Helped protect Envato Marketplaces against copyright violations
Hey guys,
What’s the fastest and easiest way to exclude category’s form the index.php.
I’ve added this in to my functions.php file but no luck.
if (is_home()) {
query_posts("cat=-52,-1,-48,52");
}
And i tried this inside the index.php, it worked but when i ad more cat id’s it fails again.
<?php if (in_category('51')) continue; ?>
Anybody got any fresh ideas?
Try this:
<?php query_posts($query_string.'&cat=-1,-2,-3');
while (have_posts()) : the_post();
?>
You should put it in your index.php file, not in the functions.php
Also, this should help:
- Author had a File in an Envato Bundle
- Author was Featured
- Bought between 500 and 999 items
- Exclusive Author
- Has been a member for 4-5 years
- Interviewed on the Envato Notes blog
- Netherlands
- Referred between 50 and 99 users
- Repeatedly Helped protect Envato Marketplaces against copyright violations
Try this:
<?php query_posts($query_string.'&cat=-1,-2,-3');
while (have_posts()) : the_post();
?>
You should put it in your index.php file, not in the functions.php
Perfect, that worked like a charm
thanks Di
- Community Moderator
- United States
- Was featured in a podcast
- Attended a Community Meetup
- Author had a Free File of the Month
- Bought between 50 and 99 items
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Has been a member for 4-5 years
- Contributed a Tutorial to a Tuts+ Site
I’m assuming you have a normal WordPress loop in index.php. If so try before your if conditional:
<?php query_posts('cat=-52,-1,-48,52') ; if (have_posts()) : while (have_posts()) : the_post(); ?>
I prefer custom loops with WP_Query object. Quick and easy loop:
<?php //pull out recent blog posts
$recent_posts = new WP_Query();
$recent_posts?>query('showposts=5&cat=-52,-1,-48,52');
while($recent_posts->have_posts()) :
$recent_posts->the_post();
?>
<!--loop content here-->
<?php endwhile;?>
Hope that helps, WP rocks 
Edit – lol, looks like Digital Impact beat me to it 
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Item was Featured
- Author had a Free File of the Month
- Author was Featured
- Bought between 10 and 49 items
- Europe
- Exclusive Author
- Has been a member for 4-5 years
- Referred between 100 and 199 users
- Envato Staff
- Reviewer
- Community Moderator
- Venezuela
- Has been a member for 4-5 years
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Microlancer Beta Tester
- Sold between 10 000 and 50 000 dollars
- Exclusive Author
Damn I love this forums, this worked for me too!!! Awesome! Thanks. 
Perfect, that worked like a charmthanks Di
Glad to be of help 
EDIT : Drew, I had a WP theme open for editing, and I use the exact same code to remove categories. Otherwise it would have taken me longer 
- Community Moderator
- United States
- Was featured in a podcast
- Attended a Community Meetup
- Author had a Free File of the Month
- Bought between 50 and 99 items
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Has been a member for 4-5 years
- Contributed a Tutorial to a Tuts+ Site
Perfect, that worked like a charmthanks Di
Glad to be of help
EDIT : Drew, I had a WP theme open for editing, and I use the exact same code to remove categories. Otherwise it would have taken me longer
![]()
lol, I had a recent theme open too that I was copying and pasting from! 
lol, I had a recent theme open too that I was copying and pasting from!![]()
LOL Drew, did I just beat you at copy/pasting? 
:D
