Skip to content

Instantly share code, notes, and snippets.

@willybahuaud
Created November 28, 2013 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willybahuaud/7699576 to your computer and use it in GitHub Desktop.
Save willybahuaud/7699576 to your computer and use it in GitHub Desktop.
Gist pour illustrer la redirection du template, si la requête est faite en ajax, sur l'article de BoiteAWeb
add_filter( 'template_include', 'baw_template_include' );
function baw_template_include( $template ) {
if( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && $_SERVER['HTTP_X_REQUESTED_WITH']== 'BAWXMLHttpRequest' ):
$pre = dirname( $template );
$suf = basename( $template );
$_template = $pre . '/ajax-' . $suf;
if( !file_exists( $_template ) )
$_template = $template;
$template = $_template;
endif;
return $template;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment