-
-
Save Mamaduka/6204839 to your computer and use it in GitHub Desktop.
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 to 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; | |
if ( empty( $pagetemplate ) ) | |
return false; | |
$result = $wpdb->query( $wpdb->prepare( "SELECT meta_key FROM $wpdb->postmeta WHERE meta_key LIKE '_wp_page_template' AND meta_value LIKE %s", $pagetemplate ) ); | |
if ( !$result ) | |
return false; | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment