Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

It seems if you use the wp_head hook as an action to put your custom metadata into the head tags of your page, it is dependent on where the theme you are using calls the wp_head. In my case, it is at the end of the head tags.

How can I force my meta data near the top of the head tags? I have a header.php file I'm calling in using a self-made plugin. I know how to write the function code to call the header.php. I just need to know how to hook it to the start of the head tags.

Thanks, Derek

share|improve this question
    
By the way, Yoast's Wordpress SEO plugin puts social stuff at the top of the head tag area. If he managed to do, I'd like to as well. Thanks! –  Derek W Beck Sep 19 '12 at 9:41
    
Then search inside the plugin code, how he adds it. –  kaiser Sep 19 '12 at 12:58
    
his plugin is dozens of files, and I don't even know what I'm looking for. –  Derek W Beck Sep 19 '12 at 19:46
add comment

2 Answers 2

You can create a custom action hook into header.php file. Then you can use that action hook instead of wp_head in your plugins.

Here's how you can create a custom action hook into wordpress.

<?php do_action('wpse65597_do_meta'); ?>

This is how you can hook your function into that action-hook -

add_action('wpse65597_do_meta','YOUR_FUNCTION_NAME');
function YOUR_FUNCTION_NAME(){  
    // echo meta tags here  
}
share|improve this answer
    
Thanks, but my goal is to not edit the theme's header.php, as I'd have to re-encode it with every update. That's in fact why I'm working on my custom/personal functionality plugin. –  Derek W Beck Sep 19 '12 at 9:41
1  
then there'll be only action hook you can use is wp_head –  amit Sep 19 '12 at 9:42
add comment
up vote 0 down vote accepted

Okay, here's the answer:

function CustomHead() {
include('headcontent.php');
}
add_action('wp_head','CustomHead',1,1);

The key is that first "1", which sets the priority of it to run at the highest (this is an optional element, defaulting to 10, putting it at the end of the head by default). More info here: http://codex.wordpress.org/Function_Reference/add_action

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.