Skip to main content
added 750 characters in body
Source Link
Brad Dalton
  • 7k
  • 2
  • 36
  • 47

Rather than insert PHP scripts into each page what you could do is execute PHP scripts using action hookshooks with conditional tags or modify the default output of an existing function using a filter hook with conditional tag for each page.

You could also create template tags or write your own functions in a separate file and execute on any page in a custom function with conditional tag using the page I.D.

Filter Example

add_filter( 'the_content', 'execute_before_content' ); 

function execute_before_content( $content ) { 

if ( is_singular('page') && function_exists('your_function')) {

    $before_content = your_function();

    $content = $before_content . $content;

    }

return $content;
}

Action Hook Example:

add_action( 'loop_start', 'your_function' );
function your_function() {
if ( is_page('007') && function_exists('your_template_tag')): 
        your_template_tag();
endif; 
}

Rather than insert PHP scripts into each page what you could do is execute PHP scripts using action hooks with conditional tags or modify the default output of an existing function using a filter hook with conditional tag for each page.

Rather than insert PHP scripts into each page what you could do is execute PHP scripts using action hooks with conditional tags or modify the default output of an existing function using a filter hook with conditional tag for each page.

You could also create template tags or write your own functions in a separate file and execute on any page in a custom function with conditional tag using the page I.D.

Filter Example

add_filter( 'the_content', 'execute_before_content' ); 

function execute_before_content( $content ) { 

if ( is_singular('page') && function_exists('your_function')) {

    $before_content = your_function();

    $content = $before_content . $content;

    }

return $content;
}

Action Hook Example:

add_action( 'loop_start', 'your_function' );
function your_function() {
if ( is_page('007') && function_exists('your_template_tag')): 
        your_template_tag();
endif; 
}
Source Link
Brad Dalton
  • 7k
  • 2
  • 36
  • 47

Rather than insert PHP scripts into each page what you could do is execute PHP scripts using action hooks with conditional tags or modify the default output of an existing function using a filter hook with conditional tag for each page.