Skip to content
How to add meta tags to WordPress website without plugins

How to Add Meta Tags to WordPress Without Plugins

Meta tags are one of the most important things in SEO. Having and set it in the right content following SEO instruction will help you to have a better ranking on search result pages.

Today, we would like to share with you some information about meta tags and how to add meta tags to your WordPress website without plugins.

What Are Meta Tags?

Meta tags provide concise information about a website or post to search engines. It will be shown on the search result pages.

Meta Description

Meta Description Tags

They list information about the web page or post, such as the author, keywords, description, type of document, copyrights, and other core information which you think is relevant to your page. But the most important meta tag is the meta description tag.

This is an example of the meta description tag:

<meta name="description" content="This is the description sentence or short paragraph about the article or post." />

As before, the meta description tag had been shown with under 150 characters by Google, but now it’s 300 characters. Thus, you will have more space to add content to that one.

Why are the meta tags necessary?

They are important and almost must be included in the on-page SEO process. The better you optimize it, the higher the appreciation of your website by search engines.

The search bots will search for necessary information for users based on the meta tags’ and the article’s content. The page or post will rank higher in search result pages if its meta tags contain important keywords. Therefore, it should be concise and contain important keywords. It will be better for SEO if you can put the keyword to the beginner of the description is better.

Moreover, it will appear on the search result pages, so you should optimize it well and use call-to-action words in its context.

How to add meta tags to WordPress website without plugins

There are various WordPress plugins which can create meta tags for page or post well. However, it may cause your WordPress website to be slow loading because of using too many plugins on the site.

On the other hand, adding it can be done without a plugin by following simple steps below.

Step 1: Go to wp-content/themes folder, and browse the theme folder which currently being used.

Step 2: Find and open the file named functions.php.

Step 3: Add the following code to the functions.php file.

function gretathemes_meta_description() {
    global $post;
    if ( is_singular() ) {
        $des_post = strip_tags( $post->post_content );
        $des_post = strip_shortcodes( $post->post_content );
        $des_post = str_replace( array("\n", "\r", "\t"), ' ', $des_post );
        $des_post = mb_substr( $des_post, 0, 300, 'utf8' );
        echo '<meta name="description" content="' . $des_post . '" />' . "\n";
    if ( is_home() ) {
        echo '<meta name="description" content="' . get_bloginfo( "description" ) . '" />' . "\n";
    if ( is_category() ) {
        $des_cat = strip_tags(category_description());
        echo '<meta name="description" content="' . $des_cat . '" />' . "\n";
add_action( 'wp_head', 'gretathemes_meta_description');

Step 4: Update the functions.php file in your theme by saving it.

If you need to add meta keyword tag, add the code below to the functions.php file. Please note that the meta keyword tag is deprecated and not widely used by search engines. So use it with your consideration.

function gretathemes_meta_tags() {
    echo '<meta name="meta_name" content="meta_value" />';
add_action('wp_head', 'gretathemes_meta_tags');

Please note, the above lines of code should be added before closing tags of php ?>

Additionally, if you plan to choose a new theme, please repeat the same steps in functions.php in your new theme.

So, you have finished adding meta tags to your WordPress website without plugins.

As you see, the process involves with custom coding a little bit. So, you might want to learn more about coding. It's very interesting.

However, if coding is not your strength then a SEO plugin still helps. We highly recommended Slim SEO, a lightweight and automated SEO plugin for WordPress. You just need to install and activate it. There's no configuration or options. Everything is done automatically. To learn about how to optimize your WordPress site with Slim SEO, refer to this article.

Hopefully, this article will help you to make your site better. Good luck!

Leave a Comment

Scroll To Top