Geodirectory Menu on Location page only

This topic contains 10 replies, has 3 voices, and was last updated by  fbernall 10 years, 8 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #11103

    fbernall
    Expired Member
    Post count: 53

    Greetings,

    I’m not using the geodirectory as my my homepage. I would like the geodirectrory menu to only show when someone is navigating the geodirectory framework pages such as listings, etc. I want my home page to only show a link to the directory plus other links to my own content.

    I’ve tried creating a new header.php renamed to homeheader.php and included in the get_header argument the name of the header as such: <?php get_header(‘homeheader’); ?>. Then I removed the wp_nav_menu(array from the new header. However the menu still shows.

    Any help or guidance would be appreciated..

    #11106

    Simone
    Expired Member
    Post count: 3515

    Hi,

    your attempt could be successful if you make a condition where the new header will be loaded only if it is_home() or any other page you want to exclude the GD links….or you can explore the world of the GD hook_actions .. 🙂

    #11109

    fbernall
    Expired Member
    Post count: 53

    Thanks, Simone. Here’s what I placed on index.php and did not work:
    <?php
    if ( is_home() ) :
    get_header( ‘homeheader’ );
    elseif ( is_404() ) :
    get_header( ‘404’ );
    else :
    get_header();
    endif;
    ?>

    Not sure what else to do.. Thanks again..

    #11110

    Simone
    Expired Member
    Post count: 3515

    Hi,
    do not edity the index, you can either create a functions or just edit the current header.

    Right before the array with the nav menu, use the if else statement and use is_frontpage rather than is_home.
    i’ve tested on my website this, and it works

    
    
     if ( is_front_page() ) :
    	echo "home";
    	 elseif ( is_404() ) :
    echo "404";
    else :
    	 
    	  wp_nav_menu(array(
        					'container' => false,                           // remove nav container
        					'container_class' => 'menu cf',                 // class of container (should you choose to use it)
        					//'menu' => __( 'The Main Menu', GEODIRECTORY_FRAMEWORK ),  // nav name // removed because it was breaking WPML lang switcher
        					'menu_class' => 'nav top-nav cf',               // adding custom nav class
        					'theme_location' => 'main-nav',                 // where it's located in the theme
        					'before' => '',                                 // before the menu
            			'after' => '',                                  // after the menu
            			'link_before' => '',                            // before each link
            			'link_after' => '',                             // after each link
            			'depth' => 0,                                   // limit the depth of the nav
        					'fallback_cb' => ''                             // fallback function (if there is one)
    						)); 
    						
    						endif;
    						?>
    #11117

    fbernall
    Expired Member
    Post count: 53

    thanks again Simone. So are you duplicating header.php for this?

    #11118

    Simone
    Expired Member
    Post count: 3515

    Not duplicating, just using the header (in the child theme) and added the modifications above

    #11124

    fbernall
    Expired Member
    Post count: 53

    ok, so I want an entire different menu on my homepage, one that includes other pages than the ones created by GDF. So, are you saying to create a new menu, call it “home” or whatever, and then include the above code on my header.php? What if I wanted that new menu to also appear on the “author”s page?

    #11185

    Paolo
    Site Admin
    Post count: 31211

    Yes, copy header.php inside your child theme and use use the conditional tag :

    
    
    geodir_is_geodir_page()
    

    That way if it is a geodirectory page you can use 1 menu, else you use the extended one for all other non GD pages…

    Let us know,

    #11189

    fbernall
    Expired Member
    Post count: 53

    Thanks Paolo. Can you elaborate a bit more on the code? I got it working in a different way, but it has some bugs..
    Would it be something like:

    <?php if(geodir_is_geodir_page() ){
    wp_nav_menu( array( ‘theme_location’ => ‘custom_menu’, ‘fallback_cb’ => ‘fallback_menu’ ) );
    } else
    wp_nav_menu(array(‘container’ => false, ‘container_class’ => ‘menu cf’,
    ‘menu_class’ => ‘nav top-nav cf’, ‘theme_location’=>’main-nav’,
    ‘before’ => ”,
    ‘after’ => ”,
    ‘link_before’ => ”,
    ‘link_after’ => ”,
    ‘depth’ => 0,
    fallback_cb’ => ” ));
    endif;?>
    thanks again..

    #11225

    Paolo
    Site Admin
    Post count: 31211

    Hi,

    1st you need to register a new menu location in your child theme style.css: http://codex.wordpress.org/Function_Reference/register_nav_menu
    example:

    
    
    <?php
    register_nav_menu( 'gd', 'GD Menu' );
    ?>

    Than copy header.php from main theme to child theme, open it and change:

    
    
     wp_nav_menu(array(
    
        					'container' => false,                           // remove nav container
    
        					'container_class' => 'menu cf',                 // class of container (should you choose to use it)
    
        					//'menu' => __( 'The Main Menu', GEODIRECTORY_FRAMEWORK ),  // nav name // removed because it was breaking WPML lang switcher
    
        					'menu_class' => 'nav top-nav cf',               // adding custom nav class
    
        					'theme_location' => 'main-nav',                 // where it's located in the theme
    
        					'before' => '',                                 // before the menu
    
            			'after' => '',                                  // after the menu
    
            			'link_before' => '',                            // before each link
    
            			'link_after' => '',                             // after each link
    
            			'depth' => 0,                                   // limit the depth of the nav
    
        					'fallback_cb' => ''                             // fallback function (if there is one)
    
    						));

    with :

    
    
    
     if(geodir_is_geodir_page() ){
    
     wp_nav_menu(array(
    
        					'container' => false,                           // remove nav container
    
        					'container_class' => 'menu cf',                 // class of container (should you choose to use it)
    
        					//'menu' => __( 'The Main Menu', GEODIRECTORY_FRAMEWORK ),  // nav name // removed because it was breaking WPML lang switcher
    
        					'menu_class' => 'nav top-nav cf',               // adding custom nav class
    
        					'theme_location' => 'gd',                 // where it's located in the theme
    
        					'before' => '',                                 // before the menu
    
            			'after' => '',                                  // after the menu
    
            			'link_before' => '',                            // before each link
    
            			'link_after' => '',                             // after each link
    
            			'depth' => 0,                                   // limit the depth of the nav
    
        					'fallback_cb' => ''                             // fallback function (if there is one)
    
    						)); }
    else { wp_nav_menu(array(
    
        					'container' => false,                           // remove nav container
    
        					'container_class' => 'menu cf',                 // class of container (should you choose to use it)
    
        					//'menu' => __( 'The Main Menu', GEODIRECTORY_FRAMEWORK ),  // nav name // removed because it was breaking WPML lang switcher
    
        					'menu_class' => 'nav top-nav cf',               // adding custom nav class
    
        					'theme_location' => 'main-nav',                 // where it's located in the theme
    
        					'before' => '',                                 // before the menu
    
            			'after' => '',                                  // after the menu
    
            			'link_before' => '',                            // before each link
    
            			'link_after' => '',                             // after each link
    
            			'depth' => 0,                                   // limit the depth of the nav
    
        					'fallback_cb' => ''                             // fallback function (if there is one)
    
    						));}
    

    I haven’t tested it, but this should work.

    #11429

    fbernall
    Expired Member
    Post count: 53

    Thank you Paolo. This worked as long as I kept the theme-location blank on the else part of the script.. don’t know why.. Thanks again..

Viewing 11 posts - 1 through 11 (of 11 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount