Yoast SEO: Add it to your WordPress theme header

I was looking for a way to do this for an installation where WordPress had many different header and footer templates depending on the default template used in WordPress, and it’s rather simple to Add Yoast SEO to WordPress Theme Header. If you haven’t already got Yoast, click here to get it. It will import settings from other major WordPress SEO plugins.

Open up your theme’s header.php (or perhaps it’s named something else) file, find the <title> tag and replace it with this:

<title><?php wp_title(''); ?></title>
<?php do_action( 'wpseo_head' );  ?>

Yoast SEO places all of it’s own SEO output in a WordPress action called wpseo_head – so if you simple call a function named  do_action  WordPress already has to run an action, then what you get is the end result of Yoast SEO’s content output into your template.

Simple, no!? Love for Yoast!

  • Zulqarnain khan

    Whats the benefit of this, Sorry i am newbie


      No benefits – this is just for developers who may need to access Yoast without having to load wp_header()