WordPress.org

Ready to get started?Download WordPress

Forums

prevent get_header() execution (2 posts)

  1. loru88
    Member
    Posted 2 years ago #

    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

  2. s_ha_dum
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic