WordPress.org

Support

Support » Plugins and Hacks » Hacks » prevent get_header() execution

prevent get_header() execution

  • Hi
    I’m interested in prevent execution of get_header() only if some conditions have happened. There is any filter or action for this purpose?
    One solution I’ve thinked is to wrap the get_header() in another function with the condition control, like this (a rapid example)

    function conditional_get_header(){
    if( ..... )
    get_header()
    else return; //doesn't print the header
    }

    If there was a particular action or filter would be a cleaner and stable solution

Viewing 1 replies (of 1 total)
  • I don’t think so. If you look at the code for that function, I don’t see any way to avoid it loading something, though you could have it load a truncated, or even empty header file. Your solution is cleaner than loading an empty file though.

Viewing 1 replies (of 1 total)
  • The topic ‘prevent get_header() execution’ is closed to new replies.
Skip to toolbar