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:
- open the all_in_one_seo_pack.php the file is located in ../wp-content/plugins/all-in-one-seo-pack/
- find wp_head by pressing ctrl+f and then type wp_head in it ("there are four wp_head")
- replace wp_head with mr_meta ("replace them all") and save
- open the aioseop.class.php file
- 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:
- open class-frontend.php file is located in ../../plugins/wordpress-seo/fronted/
- find this line
add_action( 'wp_head', array( $this, 'head' ), 1, 1 );
- replace the red part with mr_meta
- it should be like this
add_action( 'mr_meta', array( $this, 'head' ), 1, 1 );
- 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.
0 comments:
Post a Comment