WordPress Navigation Help

I am working on a site that calls the categories of a wordpress page and displays them in the right-side navigation using a php call. I am new to php and web programming in general. Is there a way I could split the categories into two sections using a particular php call or perhaps an if-loop.

Essentially, I want to display particular categories under custom sub-headings to better organize the site. Any help, I’m currently using the following script to display my categories:

Read More
<ul><?php wp_list_categories('show_count=1&title_li='); ?></ul>

Here is my site for reference: http://www.merrimentdesign.com

Related posts

Leave a Reply

2 comments

  1. Try using your code above twice. Each time, you can use the other function arguments to limit the output to certain categories. See http://codex.wordpress.org/Template_Tags/wp_list_categories for the various ways to customize the output of the function.

    For example you could use:

    <ul><?php wp_list_categories('show_count=1&title_li=&child_of=100'); ?></ul>
    // where 100 is the parent id of all of the categories you want to print.
    
    <ul><?php wp_list_categories('show_count=1&title_li=&exclude_tree=100'); ?></ul>
    // and then show everything, but children of 100
    

    Or simply use the first string multiple times specifying different parent ids each time.

  2. By far and away your best option is to use the new menu functionality within WordPress. It’s dead straight forward to set up in your theme:

    add_theme_support( 'menus' );
    
    add_action( 'init', 'register_my_menus' );
    
    function register_my_menus() {
        register_nav_menus(
            array(
                'public-menu' => __( 'Public Menu' ),
                'sidebar-public-menu' => __( 'Sidebar Public Menu' ),
                'sidebar-members-menu' => __( 'Sidebar Members Menu' ),
                'sidebar-staff-menu' => __( 'Sidebar Staff Menu' ),
                'footer-menu' => __( 'Footer Menu' )
            )
        );
    }
    

    place that in your functions.php file (and obviously change it for your requirements).

    Then in your template file – probably sidebar.php you’ll want something like:

    <?php wp_nav_menu( array( 'theme_location' => 'sidebar-staff-menu', 'container' => false ) ); ?>
    

    And then go to the back end of WordPress (your wp-admin) and then go to Appearance > Menus and voila you’re able to drag and drop your categories to your heart’s content!

    Helpful link: http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus

    Read that, Justin Tadlock is awesome.

    Good luck.