• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2662

Original Genesis Tutorials & 5000+ Guaranteed Code

Snippets

  • Support
  • Newsletter
  • Videos
  • Log in

Premium Member? - Request custom code

Add Category List In Menu Style Columns Anywhere In Any Theme

In this tutorial, i’ll give you the PHP code you can add at the end of your child themes functions.php file which displays a list of your post categories.

You can exclude any category from this list and modify the output using the native WordPress category parameters which are extensive.

Here’s what i’m talking about:

category list

The above screen shot uses the default CSS for the Twenty Twelve nav menu however you can use your own themes existing navigation styling or add your own.

No CSS code is needed to achieve this result.

Simply replace the classes in this line of code with your own themes nav menu classes.

echo'<nav id="site-navigation" class="navigation main-navigation" role="navigation">';

The code enables you to easily exclude categories by adding the i.d to the code and the output will still look good as you can see in this image:

exclude category

Here’s the PHP code:

The PHP code includes the_content filter so it works with any theme however you can easily modify this to use your own theme specific hooks or another native WordPress action hook or filter.

Here’s what it looks like in the Twenty Fourteen theme using the code below without any tweaking of the classes or adding any CSS:

twenty fourteen

I grabbed the navigation menu classes from the header.php files

Other themes will require you to modify the classes in the PHP code.

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

PHP Code

template_include

get_body_class

if else

array

class_exists

foreach

sprintf

add_action

printf

variable

Advertise · WPEngine · Genesis · Log in

  • How Premium Membership Works
  • Sign Up
  • Support
  • Subscription Details/Invoice
  • Tagged Tutorials
  • Access-Download Problems