1

I'm using add_action( 'wp_head', 'my_noindex_follow' ); to call a function that inserts a noindex,follow robots meta tag into the head of my search results page.

Does the order in which the robots meta tag appears in the head have an effect?

If so, is it possible to specify where in the head content should go?

5
  • You should probably ask this question at the webmaster stack or stackoverflow
    – Mark Kaplun
    Commented Apr 14, 2016 at 6:04
  • Will do. I wasn't exactly sure since I thought it might involve the wp-head action. Thanks!
    – upTree
    Commented Apr 14, 2016 at 10:20
  • Once you know what is the prefered order, and if you have problem implementing it, you are welcome to ask again :)
    – Mark Kaplun
    Commented Apr 14, 2016 at 10:26
  • You might be interested in the Stack Overflow question Can the order in which adding link and meta tags on head of a webpage have any adverse effect?
    – unor
    Commented Apr 14, 2016 at 15:49
  • Great! Thank you for sharing that. It helps point me in the right direction. I also learned that we can specify the priority of our new head meta tags using wp_head content with the standard priority value. For example: add_action( 'wp_head', 'my_meta_description', 1 ); The '1' puts the new meta tag just below the <title> tag. This, along with learning more about how order might have an effect, is what I was after. Thanks again!
    – upTree
    Commented Apr 14, 2016 at 22:14

1 Answer 1

1

Meta tags can go in any order. The order won't cause you any issues unless for some reason you have a massive <head> and search engines give up on reading it all ;) (it'd have to be very big for that though so don't worry)

In regards to the Wordpress action, you can use the priority parameter on this to run your hooked function in a different order. You'll need to experiment a bit as it depends on what else is running (ie what plugins you have that are adding content here), but a lower priority number will run first and a later number will run last. The default is 10.

For example, to run your function as soon as possible:

add_action('wp_head', 'my_function', 1);

You could possibly use 0 or even a negative number there if you really want - I haven't done that before so just test if it works first.

2
  • 1
    Thanks for taking the time to answer, Tim Malone. I ended up figuring this out and I posted my findings in the comments above. Sorry, I'm a bit new to posting on Stack Overflow, so I didn't think to post as an answer so as to not waste anyone's time. Thanks again! Commented Apr 26, 2016 at 9:24
  • No problem @upTree; glad you solved it!
    – Tim Malone
    Commented Apr 26, 2016 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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