• Hello, I’m trying to create a Horizontal Menu in addition to the main menu in WordPress.

    I’ve been trying to follow the tutorial found here: http://codex.ww.wp.xz.cn/Creating_Horizontal_Menus

    I’ve added this html in the bottom of header.php page.

    <div id=”navmenu”>

    </div>

    Then I added the css underneath:

    #navmenu ul {margin: 0; padding: 0;
    list-style-type: none; list-style-image: none; }
    #navmenu li {display: inline; }
    #navmenu ul li a {text-decoration:none; margin: 4px;
    padding: 5px 20px 5px 20px; color: blue;
    background: pink;}
    #navmenu ul li a:hover {color: purple;
    background: yellow; }

    & this HTML underneath that

    <p>Archives:<?php wp_get_archives(‘format=custom&show_post_count=1&type=yearly&after=;’); ?>
    Categories:<?php echo str_replace(”,’;’, wp_list_categories(‘style=&show_count=1&echo=0’));?></p>

    But the menu doesn’t come up in a horizontal line.

    Here is my front page http://www.smokincharliebrown.com/scb/ so you can see how it’s gone wrong.

    Please help.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Try adding the CSS to your theme’s stylesheet.

    Thread Starter jloshea

    (@jloshea)

    Tried that. I added the code below in the theme’s stylesheet & got this message “Parse error: syntax error, unexpected “

    #navmenu ul {margin: 0; padding: 0;
    list-style-type: none; list-style-image: none; }
    #navmenu li {display: inline; }
    #navmenu ul li a {text-decoration:none; margin: 4px;
    padding: 5px 20px 5px 20px; color: blue;
    background: pink;}
    #navmenu ul li a:hover {color: purple;
    background: yellow; }

    Stylesheets don’t produce parse error messages. Not even when they’re really mangled. Sounds like you tried to add this to a template (.php) file instead of a stylesheet (.css) file.

    Thread Starter jloshea

    (@jloshea)

    Thanks esmi you’re an absolute star, you can’t imagine how much stress this has caused me.

    Here’s my edited code which I added to the stylesheet.

    navmenu ul {margin: 0; padding: 0;
    list-style-type: none; list-style-image: none; }
    #navmenu li {display: inline; }
    #navmenu ul li a {text-decoration:none; margin: 4px;
    padding: 4px 4px 4px 4px; color: white;
    background: 00085c;}
    #navmenu ul li a:hover {color: white;
    background: blue; }

    But I can’t seem to put the menu in the centre of the page. What do I have to edit or add to the code to do that?

    Thanks

    I can see the menu on the site right now but, in theory, you’d need to give the menu container a fixed width and margin:0 auto;.

    Thread Starter jloshea

    (@jloshea)

    I edited the code with the “auto;” but still no luck.

    #navmenu ul {margin: 0; auto; padding: 0;
    list-style-type: none; list-style-image: none; }
    #navmenu li {display: inline; }
    #navmenu ul li a {text-decoration:none; margin: 4px;
    padding: 4px 4px 4px 4px; color: white;
    background: 00085c;}
    #navmenu ul li a:hover {color: white;
    background: blue; }

    No – try:

    #navmenu {
    width:700px;
    margin:0 auto;
    }

    Adjust the width to suit.

    Thread Starter jloshea

    (@jloshea)

    Wonderful, you did it again esmi πŸ™‚

    This is the code I ended up with:

    #navmenu ul {
    width:700px;
    margin:0 auto;
    list-style-type: none; list-style-image: none; }
    #navmenu li {display: inline; }
    #navmenu ul li a {text-decoration:none; margin: 4px;
    padding: 4px 4px 4px 4px; color: white;
    background: 00085c;}
    #navmenu ul li a:hover {color: white;
    background: blue; }

    <p>Archives:<?php wp_get_archives(‘format=custom&show_post_count=1&type=yearly&after=;’); ?>
    Categories:<?php echo str_replace(”,’;’, wp_list_categories(‘style=&show_count=1&echo=0’));?></p>

    It wasn’t working in Firefox so I put back the Archives code & it worked a treat.

    I can’t sleep easy now, seriously it was really stressing me out. Thank you esmi. πŸ™‚

    Glad to hear that you got it sorted in the end. πŸ™‚

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Creating Horizontal Menus’ is closed to new replies.