Don’t use get_the_excerpt
. Just do something like:
if (is_singular() && isset($post->post_excerpt)) {
echo '<meta name="description" content="'.esc_attr($post->post_excerpt).'" />';
}
$post
is populated long before the Loop. For “single” pages it will be populated with the post to be displayed. You can grab it very early in the page load. For other types of pages– archives, capital “P” Pages– it may not have the value you expect, so watch it.
Caveats:
- That assumes that your posts all have actual excerpts. Nothing will be auto-generated from post content.
- I have no idea how you theme works. You may need to edit a theme file. You may need to build a function and hook it to a theme hook or to
wp_head
.
Related Posts:
- Using wp_trim_excerpt to get the_excerpt() outside the loop
- Remove more or […] text from short post
- How can i limit the character length in excerpt? [duplicate]
- apply_filters() and the_excerpt are giving unexpected results
- How can I create a “Read More” link using the_excerpt() on a static front page?
- Compare the_excerpt() to the_content()
- How to include line-breaks in the_excerpt?
- How to control manual excerpt length?
- How to get the unfiltered excerpt, without […] or auto-excerpting
- Remove “Continue Reading” Link From the Teaser Excerpt Only
- Display Links in Excerpts?
- excerpt in characters
- Modify youtube video size on one page and show another size on different page
- Remove Ellipses from Excerpt
- Read more tag shows up on EVERY post
- Issue with enabling formatting in excerpts in WordPress
- limit the words in the post content and add read more link
- Custom excerpt length on home page
- Excerpt Word Count
- the_excerpt() or get_the_excerpt with shortcode escape
- Limit the_excerpt in the first point (.) of the sentence
- How to show only manual / custom excerpts?
- Excerpts that don’t truncate words
- Spacing within the excerpt
- Modify Twenty Fourteen Home Page Content Limit & Add Read More Link
- Custom Excerpt is returning 52 characters and not 52 words
- Disable WYSIWYG rich text editor only on post excerpt
- “Read more” link doesn’t show up when the post length is under the excerpt length
- How do I disable excerpts on blogs and website
- How to remove “Read on” content in the_excerpt?
- the_excerpt Read More Filter
- excerpt_length not working
- How to get the excerpts of all children pages
- Custom excerpt showing first paragraph (with HTML formatting)
- Regenerate auto excerpts after updating many posts
- Read more does not show up when I write my own Excerpt
- Empty excerpt using wp_get_recent_posts
- can hyperlinks be displayed in excerpts?
- Making oEmbed work on the excerpt field
- Remove whitespace before the_excerpt();
- Different ‘read more’ links
- The excerpt: Display text OR image OR video
- How to get excerpt correctly formatted
- How to display only the excerpt in the blog/posts page with Gutenberg?
- Read More for Excerpt not working
- Twenty Fourteen: Change Read More text
- Read more on the post page itself
- wp_trim_words is trimming by character instead of by words
- Bulk add tag (or any sort of label) to posts who have custom excerpt
- adjust the_excerpt based on template page
- First letter cutting off in excerpt
- How to correctly limit the content and strip HTML?
- How to display links in excerpt? [duplicate]
- Getting the_excerpt to link to child pages [closed]
- Writing a custom excerpt function
- Getting first 20 words without excerpt
- Change excerpt length of first post
- Display oEmbed in the_excerpt
- Show read more link next to last word
- the_excerpt – want to modify password protected output
- Auto Populate Excerpt Field
- Excerpt – add the last few words of posts to the […]
- excerpt – don’t use main content if empty
- Any way to get more space for editing post excerpts
- Remove Text within Header tags in the Excerpt
- Show validation warning if no Excerpt is added
- Remove box character after excerpts. Special Character Bug
- Where is the logic that defines the excerpt?
- Line in excerpt and max 5 lines
- Show the excerpt in a loop
- Custom Excerpts Per Page
- Include post title in readmore link?
- Excerpts automatically remove paragraph space
- Excerpt using Read More Tag
- Gutenberg is Adding Additional HTML Tags When Grabbing the Excerpt
- How to show post content before read more tag (excerpt) for password protected posts?
- How to apply excerpt length only on front end?
- get_the_excerpt() issues – returns the excerpt twice or not at all?
- Bug in the_excerpt() function
- Excerpt_length nor the_excerpt not working correctly
- How to remove first three words from content and display the excerpt
- Why is my excerpts not showing if not explicitly declared?
- Excerpt content
- Show excerpts of posts on P2 Home page
- How to change the length of excerpt() method?
- How to get the nivo slider to show excerpt [closed]
- Add “Excerpt” in “Quick edit”
- Removing h3s in excerpt output?
- get_the_excerpt without images
- How to wrap “Read More” link in a DIV tag?
- Automatic excerpts
- how to get excerpt without p html tag from wordpress post
- How to get only manual excerpts?
- How to properly show the Excerpt only if it exists?
- The excerpt doesn’t add Read more
- How to get excerpt of the recent posts
- the_excerpt not displaying
- excerpt display same text
- Problem with viewing single page correctly. (taken half way down the page on click through)
- Limit the size of the post excerpt