Add PHP code before any other code in Wordpress template, on a per post basis -



Add PHP code before any other code in Wordpress template, on a per post basis -

i'm trying figure out how add together php code template, before else (line:1).

i want using custom field in post itself. i'm experimenting wordpress hooks, can seem able insert html/js, , within actual header.php, , not before it.

is there specific hook should utilize this, , also, possible add together php template in manner?

if need access custom fields of post, need hook wp hook fires after post object created , conditional functions available, before get_header fired. in functions.php file:

<?php function my_function(){ global $post; if( is_single() ){ $my_meta = get_post_meta( $post->id, 'my key', true ); // assumes custom meta returns single value if( 'value expected' == $my_meta ){ // php code run goes here } } } add_action( 'wp', 'my_function' );

php wordpress themes

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -