Inject code in the header of my template

However, I won’t be able to find the author name before entering in the loop? This isn’t completely correct. The global variable $post is set by WP_Query before the Loop begins and is set to the first post in the Loop. Since the main query runs before the template loads that means that $post is … Read more

Change header based on visitor choice

I would approach this by setting sessions. So when the user makes a selection set a session which contains the users choice. Then in wp_head write an if statement that pulls the relevant template dependant upon the value of the session.

Code to Show for One post only in head

Write a function, and define it as a callback on the wp_head hook: <?php /** * print a alternate link on head for a several post * * @wp-hook wp_head * @return void */ function wpse_162849_print_alternate_link() { //don’t do anything expect on singular pages if ( ! is_singular() ) return; // check the global post … Read more