Sunday, December 22, 2024

Exclude the category you don’t need from your menu

- Advertisement -spot_img
- Advertisement -Best Managed Hosting

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. …

- Advertisement -
Best Managed Hosting

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 :

- Advertisement -Traffic Analysts Tool

[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

- Advertisement -Traffic Analysts Tool

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

?>[/sourcecode]

- Advertisement -
Latest news
- Advertisement -



Liquid Web Storm VPS
Related articles
- Advertisement - Traffic Analysts Tool