-
fyrekcaz
When I set up a new site, I usually create an ACF group named “Layout Tweaks” or something similar. In this group, I add a few True/False ACF fields that allow me to hide site-wide items on the page, such as the header, footer, and popup.
I understand that GP has built-in features to disable the header and footer, but for visual consistency, I prefer to manage everything within my ACF group.
I’ve hidden the GP settings window and added “Disable Header” and “Disable Footer” options to my custom ACF group. By default that’s going to only hide my Beaver Themer layouts and restore the GP defaults, so I’m using this snippet to try and remove both:
add_action("wp", "zf_remove_gp_header_footer"); function zf_remove_gp_header_footer() { if (!function_exists("get_field")) { return; } $post_id = get_the_ID(); if (get_field("disable_header", $post_id)) { remove_action("generate_header", "generate_construct_header"); } if (get_field("disable_footer", $post_id)) { remove_action( "generate_footer", "generate_construct_footer_widgets", 5 ); remove_action("generate_footer", "generate_construct_footer"); } }It seems to work as expected and I believe it emulates how the built in GP settings work, is that correct or will I run into issues doing this?
-
Hi there,
The code looks good to me 🙂
-
fyrekcaz
Thank you!
-
No Problem 🙂
- You must be logged in to reply to this topic.