Forums

[resolved] Adding Categories To Menu (7 posts)

  1. kasocialmedia
    Member
    Posted 2 years ago #

    I'm wondering if anyone is able to change the menu items on elegant grunge from pages to being able to show categories. I'm kinda new to this whole "CSS" thing, so an easier fix would be better.

    Thanks.

  2. Micah Cooksey
    Moderator
    Posted 2 years ago #

    In your header.php, find <?php wp_list_pages(); ?> and replace it with <?php wp_list_categories(); ?>. If your wp_list_pages tag is inside a <ul>, use the following: <?php wp_list_categories('title_li='); ?>

  3. kasocialmedia
    Member
    Posted 2 years ago #

    Hey Micah!

    Thanks so much for the help. I've done what you said to do, but for some reason it's making the categories look all weird at the top.

    You can view my site: http://www.mattmanes.com

    Any more advice?

  4. Micah Cooksey
    Moderator
    Posted 2 years ago #

    Could you copy-and-paste your header.php to http://wordpress.pastebin.ca so I can have a look?

  5. kasocialmedia
    Member
    Posted 2 years ago #

    Here you go.

    http://wordpress.pastebin.ca/1828940

    Thanks!

    - Matt

  6. kasocialmedia
    Member
    Posted 2 years ago #

    Thanks man I figured it out. Just messed with the CSS.style sheet.

    Thanks for all your help!

  7. Micah Cooksey
    Moderator
    Posted 2 years ago #

    No problem. One thing I noticed, you should change the following code:

    <div id="menu">
            <ul>
                    <li class="page_item <?php if ( is_home() ) { ?>current_page_item<?php } ?>"><a href="<?php bloginfo('url'); ?>"><?php _e('Home.', 'elegant-grunge') ?></a></li>
                    <li class="page_item <?php wp_list_categories('title_li='); ?></li>
            </ul>
            <div class="clear"></div>
    </div>

    To

    <div id="menu">
            <ul class="nav">
                    <li class="page_item <?php if ( is_home() ) { ?>current_page_item<?php } ?>"><a href="<?php bloginfo('url'); ?>"><?php _e('Home.', 'elegant-grunge') ?></a></li>
                    <?php wp_list_categories('title_li='); ?>
            </ul>
            <div class="clear"></div>
    </div>

    Since wp_list_categories makes each page an li automatically, there's no need to encase it in an li. In your css, you can use .nav li to style your menu links.

Topic Closed

This topic has been closed to new replies.

About this Topic