Add Categories to WordPress K2 Menu

This is a simple hack to enable you to place your ‘Categories’ on the menu of the K2 Wordpress theme (or any other theme). Fortunately, the Wordpress API has a function for displaying the categories. This will make it easy for us.

Using K2, open /wp-content/themes/k2/blocks/k2-header.php. Find the <?php “wp_list_pages( ); ?> code. Underneath this, you will want to put your code. Read this page here for the full list of options. This is what I use

<?php
//List categories
wp_list_categories(‘orderby=name&include=3,16,17&title_li=’);
?>

If you aren’t using K2, you will need to find the file that displays the menu. The best place to start is in the root of your theme (/wp-content/themes/your-theme/header.php) and look for a function wp_list_pages( ); that will probably be near the <body> html tag. It might not be in the header.php file, and another good place to look is in the root/blocks folder.

0 Responses to “Add Categories to WordPress K2 Menu”


  • No Comments

Leave a Reply