0

Is there a way to exclude certain categories from a widgetised sidebar? I've got categories that are associated with custom post types and ones associated with my blog - I don't want to display the CPT categories when viewing my blog.

Any ideas? All I can think of is that I have to hard code the sidebar instead and ditch the widgetised version.

2 Answers 2

1

If i understand correctly, a quick solution could be using something like Widget Logic and create a custom menu for each category, then use whatever Conditional Tags applies.// such as is_category() or in_category( '5' ) Or, if you don't want to use a plug-in, you could try duplicating the widget and then adding the conditional tag there... hope that helps!

0

The categories in widget are retrieved in following way:

wp_list_categories(apply_filters('widget_categories_args', $cat_args));

So you can make use of this filter to modify arguments.

However it might be simpler to use alternative widget, for example one from Widgets Reloaded, that offers more control via interface.

2
  • I don't want to use a plugin. Where do I find this: wp_list_categories(apply_filters('widget_categories_args', $cat_args));
    – Evie Milo
    Commented Oct 17, 2011 at 9:31
  • @Evie Milo this is code from widget. You can hook into widget_categories_args to adjust the arguments, used to retrieve the categories in widget. See Plugin API > Filters if you need info about hooks.
    – Rarst
    Commented Oct 17, 2011 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.