Page load

//************************************************************
//************************************************************
//********** HIGH LEVEL FILTERING & VALIDATION HOOK **********
//************************************************************
//************************************************************
//"wp" runs immediately after the global WP class object is set up, it is an effective place to perform any high-level filtering or validation, following queries,
//but before WordPress does any routing, processing, or handling. It is run in the main() WP method in which the $query_args are passed to parse_request(), as well
//as when send_headers() , query_posts(), handle_404(), and register_globals() are setup.
add_action( 'wp', 'mysite_wp' );
function mysite_wp()
{
	
}
//*************************************************
//*************************************************
//********** TEMPLATE PAGE ABOUT TO LOAD **********
//*************************************************
//*************************************************
//Hook executes just before WordPress determines which template page to load. It is a good hook to use if you need to do a redirect with full knowledge of the
//content that has been queried.  NOTE THIS DOES NOT FIRE FOR ADMIN PAGES!
add_action("template_redirect", 'mysite_template_redirect');
function mysite_template_redirect()
{
	
  if( ($_SERVER["REQUEST_URI"] == '/members/') && !(is_user_logged_in()) )
  {
    wp_redirect( home_url( '/' ) );
    die;
  }
	
	//echo "<h1>TEST</h1>";
}

In Header area

//***********************************************
//***********************************************
//********** HEADERA AREA IN WORDPRESS **********
//***********************************************
//***********************************************
add_action('wp_head', 'custom_header_code');
function custom_header_code()
{

  $HtmlOutput = "";
  $HtmlOutput .= <<<_END

    <!----- DISABLE CACHING OF PAGES----->
    <meta http-equiv="cache-control" content="max-age=0" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="expires" content="0" />
    <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
    <meta http-equiv="pragma" content="no-cache" />

_END;

  echo($HtmlOutput);
}

Just after body tag

//***************************************************
//***************************************************
//********** TOP OF BODY AREA IN WORDPRESS **********
//***************************************************
//***************************************************
//(Note not all themes have wp_body_open hopok, its quite new)
add_action('wp_body_open', 'custom_content_after_body_open_tag');
function custom_content_after_body_open_tag()
{
  $HtmlOutput = "";
  $HtmlOutput .= <<<_END


_END;

  echo($HtmlOutput);
}

In Footer area

//**********************************************
//**********************************************
//********** FOOTER AREA IN WORDPRESS **********
//**********************************************
//**********************************************
add_action('wp_footer', 'custom_footer_code');
function custom_footer_code()
{
  $HtmlOutput = "";
  $HtmlOutput .= <<<_END



_END;

  echo($HtmlOutput);
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *