Created
August 11, 2013 09:21
-
-
Save remkus/6204142 to your computer and use it in GitHub Desktop.
How tot detect is a certain page template is in use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@deFries updated snippet, you can see my fork here - https://gist.github.com/Mamaduka/6204839