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:
- Remove more or […] text from short post
- How can i limit the character length in excerpt? [duplicate]
- How can I create a “Read More” link using the_excerpt() on a static front page?
- How to include line-breaks in the_excerpt?
- How to control manual excerpt length?
- excerpt in characters
- Remove Ellipses from Excerpt
- the_excerpt() or get_the_excerpt with shortcode escape
- 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
- How to remove “Read on” content in the_excerpt?
- excerpt_length not working
- Read more does not show up when I write my own Excerpt
- can hyperlinks be displayed in excerpts?
- Making oEmbed work on the excerpt field
- 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
- adjust the_excerpt based on template page
- First letter cutting off in excerpt
- How to display links in excerpt? [duplicate]
- Getting the_excerpt to link to child pages [closed]
- Show read more link next to last word
- the_excerpt – want to modify password protected output
- Excerpt – add the last few words of posts to the […]
- excerpt – don’t use main content if empty
- Show validation warning if no Excerpt is added
- Remove box character after excerpts. Special Character Bug
- Include post title in readmore link?
- 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?
- 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?
- How to get the nivo slider to show excerpt [closed]
- Add “Excerpt” in “Quick edit”
- Removing h3s in excerpt output?
- How to wrap “Read More” link in a DIV tag?
- Automatic excerpts
- how to get excerpt without p html tag from wordpress post
- the_excerpt not displaying
- Text with special class as excerpt (or exclude special class)
- Display post excerpt instead of content, if available
- Add custom read more to the_excerpt and
- Remove [ and ] from excerpt
- Post excerpt in custom meta box… help with proper php format
- Is it possible to use words as starting and ending points of excerpt parameters?
- PHP Code in excerpt?
- How to replace get_the_excerpt with first N words of post article while stripping html
- Limiting the number of characters in the except
- Private Post BUT Public excerpt on Homepage
- Replacing the ellipsis with three dots
- The excerpt suffix won’t go away
- Adding […] string for a custom excerpt function
- Make only the image an anchor link using the advanced excerpt plugin?
- Replace text in excerpt
- Why archive page can’t show full content?
- How to achieve two different excerpt types on one WordPress site?
- Manual excerpt length on recent posts slider
- Remove ‘read more’ link when post is shorter than excerpt
- Excerpt not alway available
- Continuum Theme – Excerpt length
- Prevent Advanced Excerpt from Being Called
- “Continue reading” not on some posts, full excerpts not shown
- Get the automatic excerpt from a page created with gutenberg
- Read More excerpt link on a post is not linking to the post itself
- Relia Theme Homepage Articles Excerpt displays the current page excerpt not the posts being pulled
- get_the_excerpt only returns one excerpt
- How to extract an excerpt from a specific page?
- Display Full Content Instead of Excerpt
- How to use limit post content on archive page in WordPress?
- Remove Default Read More Link in Manual Excerpt RSS Feed
- How to custom excerpt?
- “read more” tag for excerpt() won’t show full content
- Unable to show excerpts
- modify text at the bottom of excerpt editor
- excerpt button not going to custom post page
- Excerpt preview
- Excerpt “Read More” link
- Force authors to use Manual Excerpt in WordPress and multiple Manual Excerpts
- Manual excerpt being ignored on custom post type
- Remove “[ ]” from excerpt in highlight search term
- Excerpt filter is adding ” in incorrect place
- Trimming breaks up markup
- WordPress excerpt with formatting and allowing selected tags
- multiple excerpt length and styles
- How to display page excerpt with readmore link inside an enhanced widget?
- how to use the_excerpt for two post queries?
- Excerpt Problems
- Function to shorten string without cutting off last word
- Implementing a blog excerpt in custom theme
- Get the excerpt of post_content
- Get a raw value of excerpt
- Excerpt length and alignment [duplicate]
- Opening file, editing, save, exit, open, edited version opens?
- Is there a way to display the ‘Read more’ link if it’s within a range?
- HTML in excerpt WordPress 6.2.2