[Support request] Secondary menu only on a given page

Home Forums Support [Support request] Secondary menu only on a given page

Home Forums Support Secondary menu only on a given page

  • This topic has 3 replies, 2 voices, and was last updated 6 years ago by Leo.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #539917
    steveb

    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?

    #540200
    Leo
    Staff
    Customer Support

    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.

    #540678
    steveb

    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.

    #541057
    Leo
    Staff
    Customer Support

    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.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.