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!

5 thoughts...

  1. Zulqarnain khan says:

    Whats the benefit of this, Sorry i am newbie

    1. SSULLIVAN88 says:

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

      1. Zulqarnain khan says:

        Okay, And your VestaCP cant be installed anymore, i tried on 2 different servers 3 times, I am always stuck here, for hours its downloading clamd https://uploads.disquscdn.com/images/80f714eb18ae2e497719e06b80cddf07e78b434103b3cbf1f23951fb5185610c.png

        1. SSULLIVAN88 says:

          I would ask on the VestaCP forums as where it stops is during a VestaCP install.

          1. Zulqarnain khan says:

            Okay, Let me make a thread there.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>