• babyskill

    (@babyskill)


    When WordPress 3.0 was launched, many people did not know about how to add a home page link in the WordPress 3.0 Menu. The simple solution was to add home-page link as a Custom Link to the menu. Well in this article, we will show you how you can show home page link under the pages widget in WordPress 3.0 menu system. This is something that all theme developers should have in their WordPress 3.0 compatible themes.

    First open your theme’s functions.php file and paste the following code:

    function home_page_menu_args( $args ) {
    $args['show_home'] = true;
    return $args;
    }
    add_filter( 'wp_page_menu_args', 'home_page_menu_args' );

    Once you have pasted this code, It should add “Home” as an option under the “Pages” widget on the Menu management page so the user can simply check it off as an item to add to their custom menu.

    [sig moderated as per the Forum Rules]

Viewing 4 replies - 1 through 4 (of 4 total)
  • alpha_llama

    (@alpha_llama)

    I’m working on a twentyten child theme that uses a jquery drop-down nav and am struggling trying to add a class to the surrounding ul element in the main navigation. If I first define a primary navigation menu, then wp_nav_menu() is used to generate the list and I can easily filter it like this:

    function my_wp_nav_menu_args( $args = '' ){
       $args['container'] = false;
       $args['menu_class'] = 'sf-menu';
       return $args;
    }

    Problem is, when twentyten falls back to using wp_page_menu, I can’t pass the arguments I need to get what I want.

    Any ideas how to remove the surrounding div and add a class to the ul nav element?

    Thanks.

    alpha_llama

    (@alpha_llama)

    nm. Got it thanks to this post.

    Here’s the code from it:

    function add_menuid ($page_markup) {
    preg_match('/^<div class=\"([a-z0-9-_]+)\">/i', $page_markup, $matches);
    $divclass = $matches[1];
    $toreplace = array('<div class="'.$divclass.'">', '</div>');
    $new_markup = str_replace($toreplace, '', $page_markup);
    $new_markup = preg_replace('/^
    
      /i', '<ul class="'.$divclass.'">', $new_markup); return $new_markup; } add_filter('wp_page_menu', 'add_menuid');
    motohall

    (@motohall)

    Heeellllpppp! I just tried what you suggested, babyskil,l and I now everything in my dashboard has gone haywire. I can’t even choose the option again in my themes functions to change it back again?
    Everything I copied and pasted went to the top of my dashboard screen instead.

    Please, please, please can you help?

    motohall

    (@motohall)

    Panic over, I’ve sorted it. It has shot half my dashboard down onto a second page and the copy and paste stuff was pasted all over the place? Managed to get the the template again and delete what I had pasted over there.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to Show Home Page Link in WordPress 3.0 Menu’ is closed to new replies.