- This topic has 13 replies, 3 voices, and was last updated 3 years, 4 months ago by
Ying.
-
AuthorPosts
-
December 22, 2022 at 9:08 am #2470717
Erwin
Hello, I have disabled the primary navigation element for one page specific. I would like to disable this for desktop only and keep the hamburger navigation for the mobile version. What would you recommend?
December 22, 2022 at 11:34 am #2470842Ying
StaffCustomer SupportHi Erwin,
Try this snippet and replace the
100with your layout element’s ID.add_filter( 'generate_element_display', function( $display, $element_id ) { if ( 100 === $element_id && wp_is_mobile()) { $display = false; } return $display; }, 10, 2 );December 23, 2022 at 2:15 am #2471294Erwin
Hi Ying,
Thank you for your reply.
What element do you mean? For the record, I don’t want to show the primary navigation on a specific page (what is easy, I just disabled the “primary navigation” element at the page settings”. But I do want to show this primary navigation on the mobile phone.
So what do you mean with my layout element ID?
Thanks in advance.
December 23, 2022 at 2:20 am #2471300Fernando Customer Support
Hi Erwin,
Ying is referring to creating a Layout Element to do this. Reference: https://docs.generatepress.com/article/layout-element-overview/
Specifically,
1. Create a Layout Element.
2. Disable the Primary Navigation in the Element: https://docs.generatepress.com/article/layout-element-overview/#disable-element
3. Set it to display on the page you want the Navigation hidden.
4. Add the code here as instructed by Ying: https://generatepress.com/forums/topic/disabled-element-primary-navigation-desktop-only/#post-2470842Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
Getting the Element ID(This is what Ying means with regards to the Layout ID): https://share.getcloudapp.com/YEuDdrnQHope this clarifies.
December 23, 2022 at 2:36 am #2471313Erwin
Hi Fernando,
Thanks, I followed your steps and added the snippet of Ying. But it is not working.
December 23, 2022 at 2:44 am #2471315Fernando Customer Support
Can you provide Admin Login credentials?
We’ll check why it isn’t working.
Please use the Private Information field for this: https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information
December 23, 2022 at 2:46 am #2471320Erwin
Yes
December 23, 2022 at 2:50 am #2471322Fernando Customer Support
How did you add the snippet here?: https://generatepress.com/forums/topic/disabled-element-primary-navigation-desktop-only/#post-2470842
December 23, 2022 at 2:56 am #2471332Erwin
FTP in functions.php of the child theme
December 23, 2022 at 2:59 am #2471335Fernando Customer Support
I see. Can you try adding it through plugin Code Snippets first so we can see it on the backend and see if it’s working?
December 23, 2022 at 3:08 am #2471344Erwin
I have removed the snippet from functions.php and added the plugin. Is this OK?
December 23, 2022 at 12:21 pm #2471860Ying
StaffCustomer SupportHi Erwin,
I’m not able to see the snippet or the plugin in admin as your site is a multi-site install and the account doesn’t have super admin access.
But I checked the layout element, and the ID is
1156, so you need to replace the100with1156in my codeDecember 23, 2022 at 10:46 pm #2472096Erwin
Hi Ying,
Believe it or not, I definitely forgot to add the ID. Very stupid, apologies. (again) Thank you so much for your help.
Happy Holidays.
December 26, 2022 at 11:47 am #2474033Ying
StaffCustomer SupportNo Problem, glad to help 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.