Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Disable Beaver Themer Layouts & GeneratePress Defaults

  • 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 🙂

  • Thank you!

  • No Problem 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.