How to Add a Meta Tag in WordPress?(2 Easy Methods)
Struggling to add a meta tag in WordPress?
Everyone wants their WordPress page and content to be noticed by a maximum number of users. Thus, every aspiring website content creator wants to learn the search engine optimization process (SEO). It typically involves making a few small changes to different aspects of your website.
Even while they can appear as small improvements when seen independently, these modifications could have a significant impact on the user experience and speed of your WordPress site in organic search results when combined with additional optimizations. Meta tags in WordPress are one of the SEO tools to optimize websites.
What Is a Meta Tag in WordPress?
A meta description WordPress is a summary of the content of your page. The header of your website contains the HTML meta tags for the meta keywords and meta description. You may easily add WordPress SEO plugins from your WordPress admin area for each post and page on your website.
Why Meta Tags Are Important?
An important aspect of website optimization is to add keywords and meta tags in WordPress. These are words that are encoded in the HTML of a website. They are designed specifically for search engines, who can scan them and understand right away what a website is about. If the website or post’s meta tags have significant keywords, they will appear higher on search result pages. As a result, it must be succinct and include significant phrases.
In addition to the page’s actual content, search engine crawlers also download metadata data in the form of meta tags when they visit your website. Meta tags allow us to tell crawlers specifics about the web pages such as type of document, author, language, copyright, etc.
How to Add a Meta Tag in WordPress?
Let us quickly learn how to add a meta tag in WordPress to your WordPress website. WordPress does not by default support meta tags, however, you may add support for meta tags to your WordPress website by following a few simple steps.
Generally speaking, there are two ways to enable meta tags in WordPress: you can either directly modify the code files or you may deploy an external plugin. This blog will help you with both methods to add meta tags in WordPress.
Method 1: Adding a Meta Tag in WordPress Manually
Let’s quickly go through a few simple steps given below to add a meta tag in WordPress without using plugins.
Step 1: Go to functions.php
Navigate to the wp-content/themes folder and look through the folder for the active theme. Then, open the PHP file.
Step 2: Add Script
Add the following script to the functions.php file.
function hueman_add_meta_tags() {
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', 'hueman_add_meta_tags');
Step 3: Save the Edits
Modify the functions.php file in your theme and save it. Add all the codes before closing PHP
Note: Donāt add too many meta tags as it could rank your web page worse in search engines.
Method 2: Adding Meta Tags Using a Plugin
1. Install a Plugin
To begin, you could start by installing the Yoast SEO Plugin. Yoast SEO may be found by performing a search for it on the Plugins area of your dashboard.
2. Activate It
After installation, activate the plugin.
3. Add Metatags
Depending on the type of content you want to add meta tags to, go to Pages > All or Posts > All after activating the plugin. Scroll down to the Yoast SEO area at the bottom of the screen after clicking Edit:
In the Focus Keyphrase section, type your main keyword and custom meta tag in WordPress. Then, enter your meta description by selecting the Edit Snippet option. This will appear in search engine results and should be a succinct sentence outlining the information on the page and enticing readers to click through.
4. Save And Publish
Once you are done with editing, save the post and publish it
Best Meta Tag Plugin in WordPress
1. Yoast SEO
Yoast SEO plugin is one of the most widely used SEO plugins by WordPress users. It has a clear section at the bottom of every page and post where you can add a meta tag in WordPress. Since Yoast understands high-quality content, it also suggests the best practice for a meta tag in WordPress. Also, you can go to their website and read their detailed guide for more information.
2. RankMath
RankMath is another popular plugin that helps you optimize your content. It has an amazing feature of SEO score which keeps on increasing when you optimize your content. Even if you donāt know how to get a good SEO score, RankMath offers you suggestions using which you can boost your SEO. It also has a clear section for meta tags and meta descriptions.
3. Google XML Sitemaps
Google XML Sitemaps help you create sitemaps that help search engines find your content easily. Since search engines use search bots to find good content, sitemaps help those search bots to go in the correct direction.
4. SEO Booster
SEO Booster is another SEO plugin that tracks visitors from over 500 Search engines. It is an excellent addition to your website that helps you select keywords, find backlinks, monitor 404 errors, and enter meta tags and meta descriptions. With all the features you would expect from an SEO plugin, SEO Booster is easy to use and works amazingly for beginners.
5. The SEO Framework
Last on the list is The SEO Framework plugin. It is an easy-to-use and lightweight plugin that helps you optimize your meta tags in WordPress. Everything in the plugin is streamlined and can be used by developers at any skill level.
FAQs
1. What is a meta tag in WordPress?
Meta tags are snippet text that gives brief information about your content on the respective page or post. It helps search engines figure out what your content is about.
2. Which is the best plugin for adding a meta tag in WordPress?
In the above article, we have listed 5 different meta tag plugins but we will suggest you use the Yoast SEO plugin. it allows you to add a meta tag by providing a meta tag field at the end of every page and post.
3. How do I add a meta tag to my WordPress blog?
There are two ways to add meta tags in WordPress. First is the manual way, where you will have to add code to functions.php. The second method is by using a plugin where you just have to enter the meta tag in the given respective field.
Wrapping Things Up
And thatās it for this blog. We hope this blog has helped you in creating and optimizing a meta tag in WordPress. If you still have any issues with meta tags or if you still canāt figure it out, you can hire WordPress engineers from JustHyre.
If you like reading this blog, also read our step-by-step guide on How To Add Custom CSS WordPress Code easily On WordPress ? (3 methods) and How to Export/Import Menu in WordPress? (2 Easy Methods).
Stuck Somewhere?
Connect With JustHyre
Hire WordPress Engineers for custom jobs like Website Customization, SEO Optimization, Clearing a Hacked Website, Installation & Configuration & more.
Connnect with JustHyre
0 Comments