• Resolved nasspray

    (@nasspray)


    i’m trying to make the menu in the theme Crafty Cart to work with “wp_nav_menu” so it’s easy to edit the menu from the backend panel of WordPress.

    The navigation.php in Crafty Cart looks like this:

    <ul id="nav">
    <li class="nav-start">
    <?php wp_list_pages('title_li=&depth=2'); ?>
    <li class="page_item last-page-item rss">" title="News Feed">RSS
    <li class="nav-end">

    Can somebody help me so that the menu will be modified to work with menu editing in WordPress 3.0>?

    Thanks

    [Please post code snippets between backticks or use the code button.]

Viewing 6 replies - 1 through 6 (of 6 total)
  • First you need to activate the theme to use the nav menu in WordPress. To do this add the following to your themes functions.php file:

    // sets up the use of wordpress menus - one of them.
    	function pj_menu() {
    		register_nav_menu( 'navbar-menu', __( 'Top Menu' ) );
    	}

    Then replace the code you have pasted above with the following:

    <?php wp_nav_menu( array( 'container_id' => 'navbar', 'theme_location' => 'navbar-menu', 'menu_id' => 'nav' ) ); ?>
    Thread Starter nasspray

    (@nasspray)

    Didn’t work for me:/

    Should i put the :

    // sets up the use of wordpress menus - one of them.
    	function pj_menu() {
    		register_nav_menu( 'navbar-menu', __( 'Top Menu' ) );
    	}

    Between the:

    }
    ?>

    in the end? or after that?

    And should I make the navigation.php looks like this:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Try this:

    function pj_menu() {
    	register_nav_menu( 'navbar-menu', __( 'Top Menu' ) );
    }
    add_action( 'after_setup_theme', 'pj_menu' );

    The problem is that without an add_action() call for the function, the function will never execute.

    Thread Starter nasspray

    (@nasspray)

    Try this:
    function pj_menu() {
    register_nav_menu( ‘navbar-menu’, __( ‘Top Menu’ ) );
    }
    add_action( ‘after_setup_theme’, ‘pj_menu’ );
    The problem is that without an add_action() call for the function, the function will never execute.

    Awesome that worked!

    Now it’s only the navigation.php that makes it looks bad. I have changed from this:

    <ul id="nav">
    	<li class="nav-start">?</li>
    	<?php wp_list_pages('title_li=&depth=2'); ?>
    	<li class="page_item last-page-item rss"><a href="<?php bloginfo('rss2_url'); ?>" title="News Feed">RSS</a></li>
    	<li class="nav-end">?</li>
    </ul>

    To this:

    <ul id="nav">
    	<li class="nav-start">?</li>
    	<?php wp_nav_menu( array( 'container_id' => 'navbar', 'theme_location' => 'navbar-menu', 'menu_id' => 'nav' ) ); ?>
    	<li class="page_item last-page-item rss"><a href="<?php bloginfo('rss2_url'); ?>" title="News Feed">RSS</a></li>
    	<li class="nav-end">?</li>
    </ul>

    But that doesen’t look nice, any clue how that code should look like?

    wp_nav_menu() wraps its output in <ul> tags, with no particularly easy way to remove them.

    I would suggest that you add your RSS feed link as a “Custom Link” menu item. Then replace all this:

    <ul id="nav">
    	<li class="nav-start"> </li>
    	<?php wp_nav_menu( array( 'container_id' => 'navbar', 'theme_location' => 'navbar-menu', 'menu_id' => 'nav' ) ); ?>
    	<li class="page_item last-page-item rss"><a href="<?php bloginfo('rss2_url'); ?>" title="News Feed">RSS</a></li>
    	<li class="nav-end"> </li>
    </ul>

    …to this:

    <?php wp_nav_menu( array( 'container_id' => 'navbar', 'theme_location' => 'navbar-menu', 'menu_id' => 'nav' ) ); ?>

    Whatever you’re doing with <li class="nav-start"> </li> and <li class="nav-end"> </li> can probably be replicated in another way.

    Thread Starter nasspray

    (@nasspray)

    Awesome thanks guys for all your help!!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Change wp_list_pages to wp_nav_menu’ is closed to new replies.