How to edit wordpress theme functions.php

How to add meta tag description of your wordpress blog?

 


While updating my website SEO, I notice that there is no meta tag description in html page. It is important to tell the search engine the summary of the page content and it also the best way to describe what is it to the readers.

Here is how to hook or add meta tag description on your WordPress blog. I am using Avada Version 3.7.3 and find out that there is no built in meta tag description. The reason why it is not always built-in on the header theme is to give advantage of using SEO plugin. I hope on the future update there will be good theme option for meta tag description and other SEO related meta tags. I don’t have any SEO plugin that manipulate meta tags so I need to add extra code to my theme function.

I suggest that it’s mandatory for you to install child theme if you are using Avada theme because of its frequent update. Having your own child theme is also a good practice as developer to work with your own codes without worrying the updates of the parent theme.

How to update meta tag description in WordPress theme function?

Go to your appearance editor and edit your theme functions. Give a space to copy and paste this code and edit some description of your blog.

add_action('wp_head', 'dlysen_meta_description');
function dlysen_meta_description(){
$description = "Blog description goes here";
if ( (is_home()) || (is_front_page()) ) {
echo "";
} elseif (is_single()) {
$description= get_the_excerpt();
echo "";
}
}

This will insert code between head tag of your html page and we are inserting meta tag description on this tutorial.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.