• Hi there,

    I have a different menu for the woocommerce part of my site but some woocommerce pages don’t have this control option in OceanWp such as the product category page. Is there a way to assign this different menu to such pages as well?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Hello,

    Please add the below snippet code in the functions.php file of your child theme and check.

    function prefix_custom_menu( $menu ) {
        if ( is_category( 'cptslug1' ) || is_category ( 'cptslug2' ) ) {
            $menu = 'catemenu';
        }
        return $menu;
    }
    add_filter( 'ocean_custom_menu', 'prefix_custom_menu' );

    PS- Do the required changes in the above code as per need like category slug and menu name.

    Thread Starter arrami1

    (@arrami1)

    Hi,

    Thanks a lot for helping out! I changed ‘cptslug1’ and ‘cptslug2’ to my category slugs and ‘catemenu’ to my menu id-name and added the code to my functions.php but nothing happened. Am I missing something? Should I leave ‘ocean_custm_menu’ as it is? I am using this for my main menu by the way.

    Abhishek

    (@abhikr781)

    Yes, please don’t change the ‘ocean_custm_menu’

    Can you please share the exact code which you have added and not working?

    Thread Starter arrami1

    (@arrami1)

    This is what I added to the function.php

    function prefix_custom_menu( $menu ) {
    if ( is_category( ‘mycategory1slug’ ) || is_category ( ‘mycategory2slug’ ) ) {
    $menu = ‘menu-shop-menu’;
    }
    return $menu;
    }
    add_filter( ‘ocean_custom_menu’, ‘prefix_custom_menu’ );

    By the way I would also like to hide the footer from category pages. If it’s no trouble may be you can show me that too?

    Thank you very much!

    Abhishek

    (@abhikr781)

    Hello,

    Thank you for sharing your code.
    Have you created your categories with the slug name “mycategory1slug” and “mycategory1slug”?

    If yes, then it should work.

    You just need to replace the cptslug1 and cptslug2, with your category slug name. and catemenu name with your menu name.

    For removing the footer, kindly share your page URL to check it.

    Thread Starter arrami1

    (@arrami1)

    Thank you for responding! Yes I think I did everything like you said but nothing happens.
    Here are some details, I would appreciate if you can check what I am doing wrong:

    Url of the shop part of the page: https://arte-flamenco.nl/shop/
    Name of the menu that I like to have on all shop-related pages: “Shop menu”, menu-id: “menu-shop-menu”

    So what I would like to achieve is that all my shop related pages (for now “product category” and “product tag pages”) would have “shop menu” as their main menu AND that they don’t have a footer bottom. Obviously I have been able to achieve this for the shop page and product pages with the OceanWp settings but not for category and tag pages.

    Thanks again!

    Abhishek

    (@abhikr781)

    Hello,

    That is quite odd, the above code should work.
    Are you using the official child theme or created with any plugin?

    function prefix_custom_menu( $menu ) {
    if ( is_category( ‘mycategory1slug’ ) || is_category ( ‘mycategory2slug’ ) ) {
    $menu = ‘menu-shop-menu’;
    }
    return $menu;
    }
    add_filter( ‘ocean_custom_menu’, ‘prefix_custom_menu’ );

    Suggest you please use the official child theme: https://docs.oceanwp.org/article/90-sample-child-theme

    and the footer seems already disabled because not getting on any page.

    If you are still experiencing the issue, I would ask you to please share the snapshots of Appearance > Menu, after selecting the theme which you want to use.
    and snapshots of you categories.

    Thread Starter arrami1

    (@arrami1)

    Thanks for following up! I have the child theme from the same link you sent me. I’m adding a screen shot of my functions.php with child theme code and your code added:
    https://arte-flamenco.nl/wp-content/uploads/2021/03/functions.php_.jpg

    Here is the screen shot of the menu I want on category and tag pages:
    https://arte-flamenco.nl/wp-content/uploads/2021/03/menu.jpg

    Here are 2 examples of pages that I’d like to have my shop menu on AND disable footer for. As you can see the footer is not disabled on these pages (because I don’t have that option on OceanWp for these pages)

    https://arte-flamenco.nl/product-category/flamenco-transcriptions/
    https://arte-flamenco.nl/product-tag/sabicas/

    I hope to find out why the code is not working. Otherwise i have to make every page myself and then redirect the category and tag pages to those but I hope that can be avoided.

    Thanks again!

    Abhishek

    (@abhikr781)

    Hello,

    Thank you for sharing the details.

    For not I got only one category, another link you have shared for the product tag.
    So please try the code with one category and check if it is working or now.

    Replace your code with the below snippet code and check.

    function prefix_custom_menu( $menu ) {
        if ( is_category( 'flamenco-transcriptions' ) ) {
            $menu = 'Shop menu';
        }
        return $menu;
    }
    add_filter( 'ocean_custom_menu', 'prefix_custom_menu' );
    Thread Starter arrami1

    (@arrami1)

    I copied and pasted your code but still it doesn’t change the menu. I had tried that before by the way.

    Abhishek

    (@abhikr781)

    That is really odd, unable found the exact causes for your issue, I need to take a closure look.

    Please try to clear your server and site cache that could be also an issue and make sure to child theme should be activated.

    In addition, go to Elementor > System Info and share the report with us so that we can take a look.

    Thread Starter arrami1

    (@arrami1)

    – I use W3 Total Cache and always clear cache to test. Don’t know about server cache.
    – Of course the child theme is active.
    – I don’t use Elementor, just Gutenberg blocks.
    I will try disabling some plugins to see if that helps. I can do that next week cause I don’t have access to my pc this week.
    Thanks for follwing up!

    Abhishek

    (@abhikr781)

    Sure, once you get PC access, please test everything.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Different menu for category pages’ is closed to new replies.