0

I have a plugin that generates a meta description or title as two of its features. However I run into the problem of other SEO plugins possibly being installed, and ending up with two meta descriptions or duplicate titles.

Ideally, I'd like to detect what is already in the <head> section and if a meta description is present, re-write it with the output from my plugin. If no meta description is present, then I simply add one (that's the easy part). Same situation for titles.

Trouble is I can't seem to find any way to get the contents of <head>, as one can with the_content in a filter or action hook. It's not an option to edit the theme as this must work regardless of the installed theme. I need a way to accomplish this using a hook or some other method from within my plugin itself.

Suggestions? Thanks!

1 Answer 1

1

Use, wp_head http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head

Ref example: Clean up output added via wp_head()

1
  • To expound on that a bit: you can find out what functions other Plugins hook into wp_head, and then make your own code conditional on if ( ! function_exists( 'other_plugin_wp_head_hook_function' ) ). Commented Jul 17, 2011 at 19:57

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.