I don’t like much third party plugins, below I described how to add SEO basic description and keywords meta tags without any additional plugin load.
- Login to WordPress admin and create new post/page, below snap I am creating new page.
- In the right top , click screen options button and enable custom fields option.
- Create new custom field description and keywords for the page then save and publish the page.
- Go to theme function.php file through ftp or admin theme editor and add below function
function add_meta_tags(){
$description = get_post_meta(get_the_ID(), "description", true);
if(empty($description)){
$description = get_the_title();
}
echo '' . "\n";
$keywords = get_post_meta(get_the_ID(), "keywords", true);
if(!empty($keywords)){
echo '' . "\n";
}
}
add_action( 'wp_head', 'add_meta_tags' ); ?>
that’s it enjoy basic SEO without additional plugin, see below page source code in the browser, our description and keywords meta tags added successfully.
For advance you can extend the same function by adding more tags like below (added for social media).
echo ''."\n";
echo ''."\n";
echo ''."\n";
echo ''."\n";