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-
AuthorPosts
-
August 5, 2014 at 10:28 pm #11103
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..
August 5, 2014 at 11:07 pm #11106Hi,
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 .. 🙂
August 5, 2014 at 11:11 pm #11109Thanks, 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..
August 5, 2014 at 11:29 pm #11110Hi,
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 worksif ( 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; ?>
August 6, 2014 at 12:09 am #11117thanks again Simone. So are you duplicating header.php for this?
August 6, 2014 at 12:09 am #11118Not duplicating, just using the header (in the child theme) and added the modifications above
August 6, 2014 at 12:43 am #11124ok, 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?
August 6, 2014 at 6:15 pm #11185Yes, 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,
August 6, 2014 at 6:33 pm #11189Thanks 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..August 6, 2014 at 9:20 pm #11225Hi,
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.
August 8, 2014 at 9:50 pm #11429Thank 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..
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket