Support » Themes and Templates » WP Filter Reference for Templates page_template,template Hook

  • I’m trying to eliminate alot of code from our templates and manage conditional statements that would appear within a specific template such as page.php , to my functions.php file. For example this appears at the top of my page.php template.

    if ( (isDest($post->ID)!=0) || (isDest($parent)!=0) || (in_array(29, $ancs))){
     	//echo "2dest</br>";
    	if (in_array(6292, $ancs) || $post->ID==6292){

    Code critique aside..I was just wondering how I could execute this code from a WP Filter or Action when the page.php template is run?

    I looked into a few Filters such as :

    applied to the template returned by the get_template function.

    So basically I would need a filter to add to the “template” hook and create a function with a conditional statement that will execute code only for a specific template?

    I understand the logistics. But Will this work and what object will I need from the global wordpress variables to see the template?

  • The topic ‘WP Filter Reference for Templates page_template,template Hook’ is closed to new replies.