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.

Dynamic meta description

The the_ID() function that you are using in your code echos the current post id, to get current post id instead of displaying it use the function get_the_ID() as shown in the following code. Alternatively you can just use get_post() function without passing any post id as a parameter because the post id parameter is … Read more

link header to homepage (for wp multisite)

A few issues- php tags are for interpolating between php/html, they can’t go within php statements. Also, the single quotes in bloginfo are closing your string, which is generating the error. Lastly, bloginfo will echo its value, which can’t go within an echo statement, you need to use get_bloginfo instead, or simpler, just use home_url(): … Read more

How do I add Facebook OpenGraph meta tags for attachments in the header for a custom theme?

$attachment_id is simply the numerical ID assigned to any media you have uploaded. You can write: echo wp_get_attachment_image(‘1′,’large’); to display the large size of image attachment with ID of 1. You should setup a new query to get all of the attachment IDs associated with the current post, then you can get_posts(‘post_type=attachment’) Check this example … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)