WordPress.org

Support

Support » Plugins and Hacks » Hacks » Menu Customisation – Urgent

Menu Customisation – Urgent

  • Greetings WordPress Community,

    I’m looking to alter the way in which my Menu operates. You can view what I am trying to achieve at: http://cleaning.greenchoicegroup.com

    I’m trying to have my menu system display Home Page only on any Sub Pages that I’ve created. In the link above, you can see that there is no “Home Page” on the front, yet I wish there to be on any of the sub-pages I create within that site.

    The purpose of this is to have a Home Page link on any sub-pages allowing them to return to the Home Page, without it displaying on the Home Page, causing confusion.

    Here is the code that handles my menu system.

    <div id="menu" class="alignleft">
                                    <?php if( function_exists('wp_nav_menu') && has_nav_menu('primary'))
                                        {
                                                    wp_nav_menu( array('menu_id'=> '','container'=>''));
                                        }
                                               else {
                                                    echo '<ul>';
                                                            wp_list_pages('title_li=');
                                                    echo '</ul>';
                                               }
                                        ?>
    			</div>
Viewing 15 replies - 1 through 15 (of 23 total)
  • Vee

    @vishalgularia

    Hi,

    Simplest way is use the the home link before you pages list:

    <ul>
    <li><a href="<?php get_settings('home'); ?>">Home</a></li>
        <?php wp_list_pages('title_li='); ?>
    </ul>

    Vishal,

    Firstly, as far as I’ve tried whenever using <li> or </li>I get errors related to them.

    Along with this, I am wanting to hide the “Home” on any of my Home Pages. But still show it on the Sub Pages.

    I’m thinking something along the lines of an if statement to load either my first, or second menu dependant on which page they’re on.

    If they’re on page one for example then Menu 1 is loaded, however page 2 loads Menu 2.

    Vee

    @vishalgularia

    What is the error you are getting.

    Use if(!is_home()) for show the home on other pages only.

    Thanks

    How would you structure that then Vishal?

    I’m trying to include the if(!is_home()) somewhere in the code I showed above, and I just displays the entire menu i’ve got.

    Edit:

    I’m getting the following error using your suggestion:

    Parse error: syntax error, unexpected ‘<‘ in [directorylistings]/header.php on line 94

    Vee

    @vishalgularia

    Use this

    <div id="menu" class="alignleft">
     <?php if( function_exists('wp_nav_menu') && has_nav_menu('primary'))
       {
          wp_nav_menu( array('menu_id'=> '','container'=>''));
       }
           else {
                echo '<ul>';
    	     if(!is_home()) echo "<li><a href=".get_settings('home').">Home</a></li>";
               wp_list_pages('title_li=');
               echo '</ul>';
                }
      ?>
    </div>

    Thanks Vishal,

    The menu is appearing as it was originally, but it appears that it isn’t hiding the Home Page link at all.

    It seems as if the if(!is_home()) isn’t working or doing its job properly. It shows on all the child pages as intended, but still shows on the Home Page.

    Would is_page(‘x’) work better?

    Vee

    @vishalgularia

    Yes you can use is_page(), add page by id, page name.

    check this : http://codex.wordpress.org/Function_Reference/is_page

    Do you suspect that there is a spelling error within it however? I’ve just noticed my coding program is colouring Home as if something isn’t closed.

    Could you check the: .get_settings(‘home’). section as fully intentional, I’ve not used .get_settings before

    Vee

    @vishalgularia

    Use get_option(‘home’)

    and check this for reference
    http://codex.wordpress.org/Function_Reference/get_option

    Doesn’t appear to work, despite my best effort I still get either errors or the Home Page isn’t showing.

    Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ in [directorylistings]/header.php on line 98

    Vee

    @vishalgularia

    post you header file code

    New Error after some changes:

    Parse error: syntax error, unexpected ‘<‘ in [directorylistings]/header.php on line 96

    Here is the entire chunk of code I am using:

    <div id="menu" class="alignleft">
     <?php if( function_exists('wp_nav_menu') && has_nav_menu('primary'))
       {
          wp_nav_menu( array('menu_id'=> '','container'=>''));
       }
           else {
                echo '<ul>';
    	     if(!is_home())
    	     	<li><a href="get_option('home')">Home</a></li>;
               wp_list_pages('title_li=');
               echo '</ul>';
                }
      ?>
    </div>
    Vee

    @vishalgularia

    Replace with this, you are making wrong syntax.

    <div id="menu" class="alignleft">
     <?php if( function_exists('wp_nav_menu') && has_nav_menu('primary'))
       {
          wp_nav_menu( array('menu_id'=> '','container'=>''));
       }
           else {
                echo '<ul>';
    	     if(!is_home())
    	     	echo "<li><a href=".get_option('home').">Home</a></li>";
               wp_list_pages('title_li=');
               echo '</ul>';
                }
      ?>
    </div>

    Still isn’t working.

    As you can see in this image (http://i.imgur.com/XPdW3.jpg) the ('home').">Home</a></li>"; appears to be coloured, as if something isn’t closed or working.

    I am thankful for you assistance so far, and I appreciate all the help. I’ve never encountered these issues before : /

    Vee

    @vishalgularia

    In the line 95, according to your image, remove the semi-colon and blank space after closing bracket tag. This is the starting of if statement. Check the code i give above.

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Menu Customisation – Urgent’ is closed to new replies.
Skip to toolbar