
Meta tags can benefit your website in several ways, but what’s the best way to add them in WordPress?
In this article, I’ll cover:
- What meta tags are
- How to add them in WordPress manually
- 3 Best plugin options
By the end of this post, you’ll know how to add meta tags in WordPress and much more.
Let’s dive in.
Table of Contents
How to Add Meta Tags in WordPress Manually
Without a plugin, there’s no easy way to add custom meta tags to each post or page in WordPress.
Because pages and posts are stored in the database, there’s no static file for you to edit or add meta tags to. Instead, the meta data will need to be automatically generated by terms such as the title, site name, and content on the page.
You can do this by adding some custom code into your themes functions.php. Or, if you prefer, you can add code in WordPress with a plugin called Code Snippets.
Either copy and paste the following code at the end of your functions.php, which you can access through the file editor, or by using the Snippets plugin:
<?php function add_meta_tags() { global $post; if (is_single()) { $meta = strip_tags($post->post_content); $meta = strip_shortcodes($post->post_content); $meta = str_replace(array("\n", "\r", "\t"), '', $meta); $meta = preg_replace('/<!--(.*)-->/Uis', '', $meta); $meta = str_ireplace('<p>', '', $meta); $meta = str_ireplace('</p>', '', $meta); $meta = substr($meta, 0, 160); $keywords = get_the_category($post->ID); $metakeywords = ''; foreach ($keywords as $keyword) { $metakeywords .= $keyword->cat_name . ", "; } echo ' <meta name="description" content="' . $meta . '" />' . "\n"; echo ' <meta name="keywords" content="' . $metakeywords . '" />' . "\n"; } } add_action('wp_head', 'add_meta_tags', 2);
The code above will use the first 160 characters of the post as the meta description. It will also use any post categories for meta keywords.
Really, this doesn’t give you much flexibility to set custom meta tags but is a completely hands-off approach.
3 Best Plugins For Meta Tags In WordPress
Here’s how you can add meta tags in WordPress with the most popular SEO plugins.
This is the way the major majority of people with WordPress sites add meta tags to their posts and pages.
1. How to Add Meta Tags Using RankMath
If you’re using the RankMath plugin, you’ll find default meta tag settings in the Posts tab under Titles & Meta.
RankMath and other SEO plugins use variable tags as placeholders, so each post and page follows the same naming convention.
Under the Single Post Type field, you will see the default values set by the plugin.
You can see the different variables by clicking the dropdown arrow.
RankMath has a ton of variables to use for your meta tags, but you’ll want to keep it as concise as possible for best results.
Here’s a great setup for your posts.
Nice and simple!
When setting your default meta Description tag, you can either choose %excerpt% or leave it blank.
Google does a good job of auto-generating the meta description from the content on the page.
If you want to create a custom meta description, you can do this from inside each post or page. More on that later.
Next, fill out the default tags for your pages and custom post types, if you have any.
A good convention for pages is to include the Post Title and the Site Title, but essentially it’s up to you to experiment with:
You can set your Separator character under the Global Meta tab.
RankMath offers a lot of features in their free plugin, but if you want more, their premium plans start from $59 per year.
Try RankMath Pro Here
RankMath Custom Meta Tags Per Post
Here’s how to add custom meta tags using RankMath.
Edit a post or page and click the button in the top right corner, then click Edit Snippet.
A popup will show with all the custom meta tag settings.
Delete the default variables and add your own catchy meta title and description.
You’ll see a preview of the search result snippet for desktop and mobile devices.
Then click on the Social tab to add different meta data for social media.
You’ll see custom settings for Facebook and Twitter. You can set the title, description and different images, and see a preview for each.
Save your post and view it to see the Meta Title appear in the browser tab.
And here it is in the code.
Try RankMath Pro Here
2. How to Add Meta Tags Using Yoast
If you’re using the Yoast SEO plugin, here’s how you can set your default meta data across all your posts and pages.
Navigate to the Content Types tab under Search Appearance to see settings for posts, pages, and any custom post types you have.
To set a default meta title, use the Yoast variables like you did with RankMath.
- Site Title – This displays the name of your website
- Title – This will display the main title of your blog post
- Primary Category – This will add the primary category of the specific post
- Separator – Separator is a character that separates each variable
You’ll want your post’s meta title to focus on the title of the page containing your primary keyword.
Your Site Title isn’t that important here.
Pages can include the Site Title because most page titles are short enough to fit them in without Google shortening the Meta Title.
You can choose a Separator character from the General Tab.
For the default Description, it’s best to leave this blank as Google and other search engines do a fairly good job of auto-generating this well enough.
Save your settings and continue reading to add custom blog post meta tags.
The premium version of Yoast provides further meta data options for social media and pricing starts at $89 per year.
Try Yoast SEO Premium Here
Yoast SEO Custom Meta Data Per Post
Here’s how to add custom meta tags using Yoast SEO.
Edit a post or page and scroll to the bottom of the page.
You’ll see the following Yoast SEO settings box.
In the fields available, delete the variables in the title and write your custom SEO optimized Meta Title and Description.
Yoast shows you a preview of what it will look like in mobile and desktop search results.
You can edit the Open Graph meta data for Facebook and Twitter from the Social tab.
Add your custom Facebook and Twitter title and description in the respective fields.
You can also add a custom image.
Optimal image size for Facebook and Twitter is between 1200x800px and 2000x1600px.
Try Yoast SEO Premium Here
3. How to Add Meta Tags Using AIOSEO
AIOSEO stands for All In One SEO, and if you’re using this plugin, here’s how to set your default meta tags across all posts and pages.
The Content types tab is under the Search Appearance link.
You’ll see similar settings to Yoast for posts, pages and any custom post types you have.
You’ll notice there are a lot more variables to choose from than Yoast. Add the Post Title tag.
AIOSEO also gives you a Google search preview.
For the description, you can leave it blank like in the Yoast example or some people like to put the Post Except:
For the plugin to pick up the except as the Description meta, you’ll need to add a custom meta description in the excerpt box per post or Google will auto-generate one from the content on the page.
Do the same for Pages but with the Separator and Site Title. AIOSEO also has a Page Content tag to use content from the page.
You can choose your Separator character from the Global Settings tab on the same page.
AIOSEO Custom Meta Data Per Post
You can edit meta tags in AIOSEO with the button in the top right corner of posts and pages or under the WordPress editor.
Delete the variable tags and enter a catchy title and description for your post to stand out in search results.
You can also create custom Facebook and Twitter titles and descriptions to optimize the way they show on these platforms.
You’ll notice there are more open graph settings in the AIOSEO free version than the other plugins.
Update your post or page and you’re done.
Try AIOSEO Pro Here
What are Meta Tags?
Meta tags are small snippets of text that describe the intention of a page on your website.
These text snippets aren’t visible on the page itself but live within the source code of the page, inside the <head></head> HTML tag.
When you have meta tags in the source code, it tells search engines and other sites, like social networks, how to show up on their platforms.
For example, the title meta tag which looks like this:
<title>33 Best Dog Toys (1,000+ Tested and Reviewed!)</title> <meta name="description" content="Are you looking for the latest must-have dog toys? After testing 1,000+ different dog toys, click here to see our top picks!" />
Will show on Google like this:
They help the users of these platforms determine what the page is all about, which can benefit the website owner in a couple of ways.
Benefits of Using Meta Tags
A major benefit of using meta tags is to improve how your pages show up in search results and on social networks.
The following, when done right, can improve your website traffic and engagement.
Improve SEO
When you use a relevant keyword in the title meta tag, this helps search engines understand what the page is about.
It’s also an on-page SEO signal in Google’s algorithm.
Pro Tip: Try to place your keyword at the beginning of the title for a small SEO signal boost.
Improve CTR from Search Results
When your page has a catchy title and description, it can attract more clicks to your site, improving your click-through rate or CTR.
This is also a key ranking factor in Google for a specific reason.
Let’s say your page is shown in the 4th position in Google and more people are clicking on your website than the 1st position.
This is telling Google that the title or description of the 4th position is more relevant and understandable to humans than the 1st position, which can move you up the results.
Pro Tip: Use attention-grabbing words in your titles to make your search results more interesting.
4 Meta Tags You Should Know About
Some meta tags are more important than others. Here are the most common ones you should know about and whether you should use them.
1. Meta Title
The meta title gets displayed as the title in search results and in web browser tabs.
Its primary purpose is to indicate the topic of the page.
Most website pages will automatically use the main heading (h1 tag) of the page for the meta title unless you use a custom title to optimize for search engines.
The meta title tag is limited to around 55 characters, in most cases.
2. Meta Description
The meta description is the short amount of text displayed under the title in search engine results.
Its purpose is to give further details about the context of the page.
Sometimes this is auto-generated by Google, taking a snippet of relevant text from the body of the page.
However, you can easily add a custom description when using one of the above plugins.
When writing your own meta description, Google suggests a length of 120-150 characters.
3. Meta Keywords
Google has ignored the meta keywords tag for years. This is because Google can understand the content of a page without them.
However, they were once used to add context to a page and potentially help get content ranked higher.
This is no longer the case.
You can still add meta keywords if you like, but it’s better to focus on the meta title and meta description instead
4. Open Graph Meta Tags
Open Graph meta tags or OG tags are a new type of meta tag, specifically targeted toward social media sites.
What this means is you can have a title meta tag for Google and then a different Open Graph title for Facebook.
<meta property="og:title" content="How to Add Meta Tags in WordPress" />
The benefits are the same as normal meta tags, in which they help users on social networks know what the content is about.
When you optimize your OG tags, you increase your chances of getting more clicks, shares, likes, and comments from sites like Twitter and Facebook.
Add Meta Tags To WordPress
The best way to add meta tags in WordPress is with a plugin, as I’ve shown you how to do this in the article, step by step.
Most SEO plugins will let you add meta tags, but the ones I’ve outlined in this post are the most popular.
They include RankMath, Yoast, and AIOSEO, which are all excellent options for adding meta tags in WordPress.