conditional statements - Wordpress - is_page_conditional -


i struggling hard is_page_template conditional.

the problem when "include" template functions file (country_template_functions.php) functions.php file, is_page_template conditional doesn't work anymore. if remove "include(template...)" functions.php work again, no solution since file has included functions.php make work.

can explain me might wrong? is_page conditional works in both cases.

if (file_exists(thesis_custom . '/country_template_functions.php')){     include(thesis_custom . '/country_template_functions.php'); }  function test() {     if ( is_page_template( "country_template.php" ) ){         echo "is page template works";     } } add_action('thesis_hook_before_header','test'); 

i using thesis theme.

edit:
seems cause problem not sure why. causes cannot use is_page_template after thesis_hook_before_content_area

add_action('thesis_hook_before_content_area',     'country_page_template_swap_before_content');  function country_page_template_swap_before_content(){     if (is_page()) {         global $post;         global $swapped_post;         $page_template = get_post_meta($post->id, '_wp_page_template', true);         if($page_template == 'country_template.php'){             update_post_meta($post->id, '_wp_page_template', 'custom_template.php');             $swap_id = time();             update_post_meta($post->id, '_country_template_swapped', $swap_id);             $swapped_post = $post;         }         else{             $template_swapped = get_post_meta($post->id, '_country_template_swapped', true);             if(!empty($template_swapped)){                 $swapped_post = $post;             }             }     } } 


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -