You’ll often have post categories for things like “Events” that you don’t want showing up on your homepage with all your other posts. This is the easy way to filter them out.
Here’s what you should put in the custom_functions.php file:
/* Filter categories on the homepage */
function home_filter_begin() {
if(is_home()):
global $wp_query;
$exclude = '-32,-165,-103,-20,-23,-21,-22,-671';
query_posts(array_merge(array('cat' => $exclude ),$wp_query->query));
endif;
}
add_action('thesis_hook_before_content','home_filter_begin');
function home_filter_end() {
if(is_home()):
wp_reset_query();
endif;
}
add_action('thesis_hook_after_content','home_filter_end');
And here’s what it means:
function home_filter_begin() {– This is the name of the filterif(is_home()): global $wp_query;– If this is the homepage, load the wordpress query$exclude = '-32,-20';– Create a variable called “exclude” that lists all the categories we’ll excludequery_posts(array_merge(array('cat' => $exclude ),$wp_query->query));– Do a new wordpress query, merging the existing one and the list of excluded categoriesendif; } add_action('thesis_hook_before_content','home_filter_begin');– End the if statement, and insert this function before the content.function home_filter_end() { if(is_home()): wp_reset_query(); endif; } add_action('thesis_hook_after_content','home_filter_end');– At the end of all the posts on the homepage, reset the wordpress query back to what it was.
- Adding “nofollow” to Category Links
- Thesis Tip #18 – Full Width Navigation
- Thesis Tip #17 – Adding Content Between Posts
- Thesis Tip #16 – Redirect Pages
- Thesis Tip #15 – Custom Author Pages
- Thesis Tip #14 – Add Related Posts Before Comments Link
- Thesis Tip #13 – Using Gravatars in WordPress
- Thesis Tip #12 – Adding Custom Headers to Category Pages
- Thesis Tip #11 – Clickable Logo in Header
- Thesis Tip #10 – Filter Categories from Homepage
- Thesis Tip #9 – Custom Options Page
- Thesis Tip #8 – Change Next and Previous Post Text
- Thesis Tip #7 – Import and Export Your Design
- Thesis Tip #6 – Print Stylesheets
- Thesis Tip #5 – Featured Content Rotator
- Thesis Tip #4 – Adding Classes to Body
- Thesis Tip #3 – Multiple content areas
- Thesis Tip #2 – Additional Sidebars
- Thesis Tip #1 – Custom Images and Category Pages
Bill Erickson is a WordPress Consultant who builds custom websites using WordPress as a CMS and Thesis or Genesis as a framework. He’s a cofounder and resident of The Creative Space, and a cofounder of the BIL Conference (the open analog to the TED Conference).

{ 1 comment… read it below or add one }
Bill, thanks for this. Will this work for Thesis 1.7? Also would you have a tutorial that shows how to change the standard 2 column layout for teasers into a 3 or 4 column layout and to only show the post image rather than the exerpt with the post image.
Please shoot me an email if you do.