WP Filter Reference for Templates page_template,template Hook (1 post)

  1. Mitchell McDeere
    Posted 5 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 5 years ago by Mitchell McDeere
  • This topic is not resolved
  • WordPress version: 3.0.5