Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 10-09-2011, 12:31 PM   #1
garce
Confirmed User
 
garce's Avatar
 
Industry Role:
Join Date: Oct 2001
Location: Toronto
Posts: 7,103
How to exclude a category from the default WP Categories widget?

I never use widgets - I can't stand the things - but I HAVE to use widgets for this project.

Using the default Categories widget, how do I exclude certain categories from being listed in the sidebar?

Update and Edit:

Ok, that was fucking simple - in spite of the massive amount of incorrect information I received from Google and its three year old (yet extremely relevant - rofl) results...

To exclude a category from the default sidebar widget, open default-widgets.php and add:

Code:
$ex = 'whateverIDthecatis,anothercatID';
under

Code:
class WP_Widget_Categories extends WP_Widget
The source told me what to do right here:

Code:
$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h, 'exclude' => $ex );
I should have just opened default-widgets.php and read the source before searching useless Google.

So, ignore this - unless I've missed something important - then I would truly appreciate your input.

Posting this only because someone may search for this information... I doubt it - no-one searches for shit - but hey!
garce is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-09-2011, 06:48 PM   #2
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,297
Quote:
Originally Posted by garce View Post
I never use widgets - I can't stand the things - but I HAVE to use widgets for this project.

Using the default Categories widget, how do I exclude certain categories from being listed in the sidebar?

Update and Edit:

Ok, that was fucking simple - in spite of the massive amount of incorrect information I received from Google and its three year old (yet extremely relevant - rofl) results...

To exclude a category from the default sidebar widget, open default-widgets.php and add:

Code:
$ex = 'whateverIDthecatis,anothercatID';
under

Code:
class WP_Widget_Categories extends WP_Widget
The source told me what to do right here:

Code:
$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h, 'exclude' => $ex );
I should have just opened default-widgets.php and read the source before searching useless Google.

So, ignore this - unless I've missed something important - then I would truly appreciate your input.

Posting this only because someone may search for this information... I doubt it - no-one searches for shit - but hey!
never edit the core files ;)

you want to hook into the filter widget_categories_args

Code:
add_filter('widget_categories_args', 'my_cats_filter');

function my_cats_filter( $args ) {
    $args['exclude'] = 2;
    return $args;
}
2 being the id of the category, if you need more than 1 make it an array of ids.
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.