Skip to content

Instantly share code, notes, and snippets.

@obiPlabon
Last active October 22, 2015 19:50
Show Gist options
  • Select an option

  • Save obiPlabon/da41ed152c2f0c6bae57 to your computer and use it in GitHub Desktop.

Select an option

Save obiPlabon/da41ed152c2f0c6bae57 to your computer and use it in GitHub Desktop.
Built in function and it's pretty helpful to understand WP global variable
<?php
function load_template( $_template_file, $require_once = true ) {
global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
if ( is_array( $wp_query->query_vars ) ) {
extract( $wp_query->query_vars, EXTR_SKIP );
}
if ( isset( $s ) ) {
$s = esc_attr( $s );
}
if ( $require_once ) {
require_once( $_template_file );
} else {
require( $_template_file );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment