Archived topic
Custom Page Templates
15 replies · Started by Matt on November 24, 2020
Hi,
I'm trying to make a custom template for a membership site. I need to create the external pages (register, sign-in, T's and C's) and I want to remove the header on these pages.
I have used the generate_header hook to remove the main header markup (https://docs.generatepress.com/article/generate_header/) but this doesn't remove the mobile nav on smaller screens. Is there a specific hook I should be looking for?
Thanks
Hi there,
Any chance you can link us to the site in question?
You can use the private information field.
Let me know :)
Hi Leo,
I think I found the hook I was looking for:
add_action( 'generate_after_header', 'generate_menu_plus_mobile_header', 5 )
I have removed this action and it seems to be doing what I was wanting.
ie
if ( ! is_user_logged_in() )
{
remove_action( 'generate_after_header', 'generate_menu_plus_mobile_header');
}
Thanks
You can actually just create a layout element for that:
https://docs.generatepress.com/article/layout-element-overview/#disable-element
Just disable the Site Header and the Mobile Header.
To remove the sites mobile navigation?
Yup - the site header and the mobile header is separated which is why your original solution didn't work for mobile.
Creating a layout element would be the best solution.
That's awesome. So just to be clear on how it works.....
1. Set up an Element of type 'Layout'.
2. Disable any of the elements that I don't want to show to non-logged in users
3. On 'Display Rules' tab - Set the location to 'Entire Site' and the Users to 'Logged out Users'
This will then over-ride page Layout settings for any page when the user isn't logged in?
Thanks
That sounds correct.
Try it first?
Hi,
Just a follow up to this topic. Is there a way with the "Elements" module to remove the mobile navigation, but not the mobile header (logo etc)?
Thanks
If you remove the primary navigation using Disable Elements, that should happen.
However, it also disables the primary nav on desktop, which may not be what you're looking for?
In that case, your best bet is to use CSS to hide the toggle in the mobile header:
#mobile-header .menu-toggle {
display: none;
}
Hi Tom,
That was my understanding too but it's not what I am seeing.
What I am trying to do is remove the menu for any user that is logged out (at any screensize).
Using the Elements module, I have set up layout for Logged Out Users that disables Primary Navigation. The display rules are set to Location - "Entire Site" and Users -"Logged Out".
When I view the site in incognito (ie. logged out) this seems to work for desktop size (navigation is not rendered in HTML), but the mobile menu is still being generated and displayed.
Aha, it seems it's only set up when using the Disable Elements metabox on the actual page (not via Elements).
This is definitely a bug - it should work with Elements as well. I'll be sure to get this added in the next GPP version (alpha coming next week).
For now, you can use the Disable Elements feature on the page, or some simple CSS to hide it for logged-out users.
Let me know if you need more info :)
Hi Guys,
Just following up an this and seeing when the bug fix is likely to make it to production. I have implemented the css fix, but would rather have it resolved before I hand over to the client.
Thanks
This fix has been implemented in the next GPP version. We're trying to get the alpha released this week.
Thanks!
Hi Tom,
Just following up on this. It seems that this issue still persists. Any timeline on a fix? Or more likely just wait until 2.0?
Thanks