Skip to content

Instantly share code, notes, and snippets.

@remkus
Created August 11, 2013 09:21
Show Gist options
  • Save remkus/6204142 to your computer and use it in GitHub Desktop.
Save remkus/6204142 to your computer and use it in GitHub Desktop.
How tot detect is a certain page template is in use.
<?php
**/
* How tot detect is a certain page template is in use.
*
* @link http://www.wupperpiraten.de/2009/12/is-a-certain-page-template-active/
*/
function is_pagetemplate_active( $pagetemplate = '' ) {
global $wpdb;
$sql = "select meta_key from $wpdb->postmeta where meta_key like '_wp_page_template' and meta_value like '" . $pagetemplate . "'";
$result = $wpdb->query( $sql );
if ( $result ) {
return TRUE;
} else {
return FALSE;
}
}
@Mamaduka
Copy link

@deFries updated snippet, you can see my fork here - https://gist.github.com/Mamaduka/6204839

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment