Exclude Categories from Sidebar – WordPress 2.8

Exclude specific categories from being displayed in the sidebar in WordPress 2.8. In the following simple solution, I show you how to keep select categories from being displayed in your sidebar on your WordPress pages and posts. This is very useful if you have a lot of categories, or have changed the content of your blog, have been indexed for the content and no longer wish to use or display specific categories on your WordPress site. Upon completion of this tutorial, the permalink structure of the hidden categories are still made available to the search engines, however, the categories you have chosen to hide are no longer displayed from your sidebar to the visitor.

Find WordPress Cat ID number

Exclude Categories from displaying in the Sidebar – WordPress 2.8:

  1. Locate which categories you would like to hide from displaying in the sidebar. Category ID's can be found from the WordPress Admin Panel under Posts > Categories. Simply hover over a category and the cat_ID=# will be listed at the bottom of your browser window.cat_ID=#
  2. Using your favorite FTP client, FTP to your WordPress installation
  3. Navigate to wp-includes/default-widgets.php and copy default-widgets.php to your desktop
  4. Open default-widgets.php with a text editor and find the following line:
  5. $d = $instance['dropdown'] ? '1' : '0';

  6. Under this line, add the following line:
  7. $ex = "1,2,3";

  8. Change 1,2,3 to reflect the category ID's you would like to exclude
  9. Next, find the following line:
  10. $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);

  11. Replace it with the following line,
  12. $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h, 'exclude' => $ex );

  13. Save the default-widgets.php file and upload it to your wp-includes directory on your server, overwriting the old file.
  14. Go view your site. Your sidebar category widget should now be displaying all but the excluded categories.

Recommended Posts:

  • No Similar Posts Detected