Every time you add a new theme to your WordPress blog and you find that this theme show all your categories in a menu. The idea of excluding a category from the menu come directly to your mind.

Today I propose to change the categories menu you have in your home page to suit your needs.

exclude-a-category-from-your-wordpress-index

Initially if you do not have this menu, and you still have the classic menu which include: Home, About, etc. …

all you have to do is using this small code in the place you think you want to show the menu in :

[sourcecode language=”php”]
<?php

wp_list_categories(‘orderby=name&title_li=0’)

?>[/sourcecode]

Now if you want to exclude a specific category add this ” &exclude=10” to your code to have something like that :

[sourcecode language=”php”]
<?php

wp_list_categories(‘orderby=name&title_li=0&exclude=10’)

?>[/sourcecode]

Where 10 is the category ID

If by any chance you want to exclude more than one category, you simply just add a comma after the number of the first category then enter the following number.

[sourcecode language=”php”]
<?php

wp_list_categories(‘orderby=name&title_li=0&exclude=10,33,454’)

?>[/sourcecode]


You May Also Like

Affect an image to categories in WordPress without plugin

This tutorial allows you to add a text field to fill the URL of an image for each of your categories. Add this in your functions.php file: [sourcecode language=”php”]add_action(‘init’, ‘my_category_module’);[/sourcecode] [sourcecode language=”php”]function my_category_module() { add_action ( ‘edit_category_form_fields’, ‘add_image_cat’); add_action ( ‘edited_category’, ‘save_image’); }[/sourcecode] The function to add the extra field : [sourcecode language=”php”]function add_image_cat($tag){ $category_images = get_option( ‘category_images’ ); $category_image = ”; if ( is_array( $category_images ) && array_key_exists( $tag->term_id, $category_images […]

5 Common Mistakes Made by WordPress Beginners

  WordPress is a global platform for beginners to start their own website. It is a free platform without any barriers to entry that allows anyone to start a website with just basic knowledge regarding web development. Since it is an extremely easy to use content management system some beginners make very common mistakes when […]

The Real Cost of “Just One More Plugin”: A WordPress Bloat Audit

Plugin count is a bad proxy for plugin cost. Here’s a category-based audit that finds real performance savings a “delete unused plugins” tip misses entirely.

WordPress Hack: remove “WordPress Generator”

The publishing platform WordPress adds a small line for itself to advertise and clarify that the site that you find is a site using WordPress. Except that in addition to reporting that it’s WordPress, it goes to show the current version.It is not embarrassing, except that each version has its security problems… Past one of […]