I needed a very simple way to custom styles or scripts to the <head>, and I didn’t really want to customize the theme.
add_action( 'wp_head', 'wp_head_custom_field' ); function wp_head_custom_field() { if ( is_single() ) { global $post; $html = get_post_meta( $post->ID, 'wp_head', true ); echo $html; } }
With this, I just needed to add my pre-formatted javascript or css to a custom field called ‘wp_head’ and it would then be added to the <head> just like I needed. I added the is_single()
as a precaution.
I still don’t utsardnend. Where does one define those two variables in order to use them in custody fields?For instance, If I were to post an image, into a post or a page, what exactly would I do?A stepwise procedure would greatly be appreciated.Cheers,mate