Home» »How to move Plugin SEO Meta Data to top

How to move Plugin SEO Meta Data to top

Generaly SEO Meta Data of a plugin seo is under the meta link, external stylesheets and even under pile of lines of the external scripts. This causes seo meta data of the plugin should wait a turn most behind to read by bots. As a result there are few external script links that get indexed, because meta data read after the external script lines.

Here is a screenshots of SEO Meta Data that is generated by the wordpress plugin:

This is how default SEO Meta Data looks like in source page :


And this is how it should be :


The screenshot above does have different SEO plugin, which one is AIOSP by Michael Torbert and the other is the Yoast SEO, but it doesn't matter, because I will show you how to move plugin SEO Meta Data to top both.

But before moving forward, the first thing you need to know is we are going to edit the plugin, and you have to edit the plugin every time the plugin get updated. But we are not going to make many changes because it is very simple, and you can do it once every week. :D

Well here are the steps to move SEO Meta Tags to top:

Creating new wp head function


Basically all the SEO plugin will shows its metadata in wp_head function. This function is located in header of your template. If you don't have this code in your template header, then few plugins won't work in your template.

This function is a default function of wordpress, and it is supposed to exist in the header of your template. But if you do not have it or you accidentally remove it, just add the code bellow to your header.php file right before closing head tag "</head>".

<?php wp_head(); ?>

Fire the wp_head action


Now I want to display the SEO meta data before the wp_head function called, then we have to create a new function that we will put it over the wp_head line.

To make a new function that similar like wp_head function, so we can use it to manage meta data position, add the following code into your functions.php file

function mr_meta() {
   do_action('mr_meta');
}

Now we have a new function that is called mr_meta, so you should use to call the function. You can change the function name if you want. After that, i want you to put the mr_meta function into your header template or the header.php file, right before wp_head line. It should be like this:

<?php mr_meta(); ?>
<?php wp_head(); ?>

Edit plugin


For AIOSP Plugin by Michael Torbert:


  1. open the all_in_one_seo_pack.php the file is located in ../wp-content/plugins/all-in-one-seo-pack/
  2. find wp_head by pressing ctrl+f and then type wp_head in it ("there are four wp_head")
  3. replace wp_head with mr_meta ("replace them all") and save
  4. open the aioseop.class.php file
  5. find and replace wp_head lines with mr_meta ("there are four wp_head, you have to replace them all too")

For Wordpress SEO Plugin by YOAST:


  1. open class-frontend.php file is located in ../../plugins/wordpress-seo/fronted/
  2. find this line
    add_action( 'wp_head', array( $this, 'head' ), 1, 1 );
  3. replace the red part with mr_meta
  4. it should be like this
    add_action( 'mr_meta', array( $this, 'head' ), 1, 1 );
  5. save file

Now your plugin meta will shown in the mr_meta function not wp_head. But you have to remember that it's will be back to default everytime you update your plugin. You can change the position of it also, its good too under the title tag. Refresh your page source and check if your SEO meta data has moved.

About Author:

Rahman Kurnia is a blogger, SEO fighter, who loves PHP, CSS, HTML and interested in js, ajax, c++ and much more. He love writing something informatif to help others, and to keep his knowledge on the internet.

Follow him @ Twitter | Facebook | Google +

0 comments:

Post a Comment

Like us on Facebook
Follow us on Twitter
Recommend us on Google Plus
Blog Widget by LinkWithin