How to Replace the_excerpt with Yoast SEO Meta Description for Improved WordPress SEO

by | March 19, 2021 | PHP, SEO, Website Development

This page may contain affiliate links to recommended products or services. If you choose to purchase after clicking a link, I may receive a commission at no additional cost to you.

Last updated on: February 8, 2023

In this article, you’ll learn how to replace the_excerpt() with the Yoast SEO meta description — for improved WordPress SEO.

Code Snippet

Any time you’re inside WordPress’ the loop, you can replace the_excerpt(); with the following code to use the Yoast SEO meta description for the current post item. Simply put, copy and paste this code into your WordPress templates where you want the blurb to display.

echo get_post_meta( get_the_ID(), '_yoast_wpseo_metadesc', true );

Remember, this goes into your WP theme’s PHP template — inside of “the loop”.

echo prints the text in the browser.

get_post_meta() is a bult-in WordPress function to get post meta field values. It accepts three arguments: the post id, the name of the field to retrieve, and a true or false boolean value that tells the function whether it should return an array (false) or simply the meta field’s value (true).

What If You Don’t Use Excerpts?

A typical WP blog page loops over your most recent posts. Usually, it looks similar to a Google search engine results page. You’ll see a post titled, followed by a short summary or blurb — lovingly known as the excerpt. It’s the teaser or lead-in to a full article — at least, it ought to be.

What if you don’t write customized excerpts for your articles?

Maybe it’s too much extra work. Maybe you’re using the full article, a character limit to auto-generate a “blurb” with a read more link, or maybe you just didn’t know using an excerpt was an option.

Regardless of why you’re not using a proper excerpt, it’s generally a good idea to use them. You can’t hurt your site by not having custom excerpts, but you definitely can’t help your site by not having custom excerpts either.

When it comes to website search engine optimization — my opinion is that everything counts. If there’s something you can do then you should do it. Eventually, you’ll surpass the competition.

Avoiding Duplicate Content

It’s also a good idea to avoid creating duplicate content issues by using the same text in multiple locations on your website.

For one, you’re creating duplicate content on your blog roll pages if you’re displaying full articles here, as well as on single post pages.

It’s a small infraction if you’re auto-generating excerpts. You might be using the first paragraph of a post or doing something that takes the first x-number of characters to create the excerpt, but technically you’re still duplicating the same content.

Ultimately, your website will work better for you if you can create unique excerpt content that maintains alignment with the article it’s linking to.

Search Engine Friendly Excerpt Solution

One search engine friendly solution to creating custom excerpts is to use an article’s meta description.

Meta descriptions are off-screen content that shows up as the descriptive text in search engine results pages.

If you’re like most people who want to get more traffic to your website then you’re really into search engine optimization. You probably take the time to carefully craft meta descriptions in hopes they’ll help with search rankings. The best meta descriptions are the ones that are aligned to both the page they’re describing, as well as the query a user has typed into the search engine — the alignment is what makes your site a match to their query.

The more aligned your landing page is to a user’s search query, the better a result it is for their search query, and the more likely your web page will continue to show up and be recommended in search engine results pages.

Serving up better SEO is a win-win-win — you win for getting traffic, the search engine wins for recommending high-quality search results, and the user wins because they find what they’re looking for.

Multi-Functional META Descriptions

You probably wouldn’t use a custom excerpt as a meta description — and definitely can’t use a full-article as a meta description — but you certainly could use a meta description as a custom excerpt. Meta descriptions are approximately 160 characters in length and their concise and to-the-point context makes them multi-functional as meta descriptions, excerpts, and posts for social media.

Since the meta description is an off-screen piece of text, you’ll never run into duplicate content issues either.

Better Alignability

In fact, it may even be better to use your custom meta descriptions as article excerpts for SEO.

A short excerpt is exactly what meta descriptions are supposed to be. The meta title is the name of the page (i.e. the H1) and the meta description is the short concise summary of the content. Why not let the meta description perform double duty and do its job to keep your page’s purpose aligned both on-site and off-site?

All in all, it seems like a good idea to me.

Keep it Simple with Yoast SEO

Yoast SEO is one of the most popular WordPress SEO plugins. It’s plug-and-play and adds fields to every post, page, and custom post type allowing you to enter a unique meta description for each. And lucky for you, that meta description is also accessible as a code snippet inside of your theme’s template files. You can use the Yoast SEO meta description in lieu of excerpts in places like your blog roll, archive, and search results pages.

Floyd Hartford is a website developer from southern Maine. He's focused on creating and building WordPress websites and loves spending time digging into code like HTML, CSS, scss, jQuery, PHP, and MySQL.


Submit a Comment

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

twenty − two =

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Looking for WordPress Help?

I’m a freelance web developer specializing in small business and corporate marketing websites.

Pin It on Pinterest