Simple way to add horizontal categories menu in WordPress without CSS


To create a horizontal categories menu separated by ‘ | ‘ in WordPress, use this code.

echo str_replace('<br />',' | ',

If you want to exclude category from the menu then add this code, Example to exclude category with id=2 :


To find the category id,
1. go to Posts > Categories.
2. Hover to any category name, and look at your browser status bar. Look for something like `…&tag_ID=2…`. In this case, the category id is 2.

Leave a Reply

Your email address will not be published. Required fields are marked *