Straightforward sticky header #68418
Replies: 3 comments 8 replies
-
@gvgvgvijayan do you think the option of having one primary template would help with this? The idea is that the primary template would contain the sticky group wrapped header, and other templates wouldn't need to include the header, so there would only be the one template to edit when making changes such as this. I opened an issue/request at #68884 but I'm not sure if it would be better as a discussion or a continuation of this discussion. |
Beta Was this translation helpful? Give feedback.
-
@Andrew-Starr Thank you for reviving this discussion and sharing your thoughts. From the engineering perspective, I think this will lead to lots of complexities. Making a primary template-part means it should encase the other template-part like header, footer, sidebar, etc. this requires dynamic DOM manipulation I guess. Plus, one primary template-part won't be ideal for all template-part encase/parent. Therefore, I leave this to WP core engineering people to do the research. |
Beta Was this translation helpful? Give feedback.
-
There would be a new block named something like "template" with block markup something like This would work in a similar way to the post content block In your primary template you would have something like the following, with the header inside a sticky group, then the new template block and the footer template part.
The other templates would not need to contain the header or footer template parts, only the blocks that you want for that particular template. For example the single template with post title and post content blocks:
The home template with query loop and pagination for example:
The primary template would be entirely optional for those who want to try it out, and to not break any existing setups. |
Beta Was this translation helpful? Give feedback.
-
Actual:
There is no direct, easy way to turn the menu into a sticky menu. Even if you set position to sticky for the group inside header template part it won't work, therefore you have to do a cumbersome way of editing all templates and encase the header part in group then apply sticky position.
Consider if the website is well matured and have many templates for each post types, archives, miscellaneous pages like 404, search, etc. Then we have to touch all templates.
The caveat is also discussed here Sticky Header one of the best site to learn about Gutenberg.
Expectation:
Sticky menu should work out of the box, plus for DX provide an API (
register_template_part_style
) to add custom class to template part as likeregister_block_style
.Summary:
Summary of Sticky Menu Challenges in Gutenberg:
Beta Was this translation helpful? Give feedback.
All reactions