Archived topic
Secondary menu only on a given page
3 replies · Started by _blank on April 3, 2018
I'd like to set the secondary menu to appear only on a given page and on its subpages.
I.E. I have a site whose primary role is informative, that contain also a small shop, let's say that it is located at http://www.example.com/shop
I want to have only the primary menu to appear on all pages of http://www.example.com, but add a secondary menu only to http://www.example.com/shop and its subpages, so also on http://www.example.com/shop/cart, http://www.example.com/shop/article1, and so on.
How can I do this?
Hi there,
I assume shop is from WooCommerce?
So basically you want secondary navigation on all the WooCommerce pages?
Also where would you like to position the secondary nav?
Let me know.
Yes, it is from WooCommerce, but I'm also interested about how to do this without this specific plugin, as a future reference.
I'd like to place the secondary nav directly under the main one, under the header.
I think this snippet should work:
add_filter( 'option_generate_secondary_nav_settings','lh_woo_secondary_nav_location' );
function lh_woo_secondary_nav_location( $options ) {
if ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) {
$options[ 'secondary_nav_position_setting' ] = 'secondary-nav-below-header';
return $options;
}
}
Basically using this method here: https://generatepress.com/forums/topic/comments-showing-in-the-wrong-place-on-blog-posts/#post-310334
With conditional tags: https://docs.generatepress.com/article/using-hooks-conditional-tags/
Let me know.