Archived topic
Display meta description in the Header Element
7 replies · Started by Takeru on February 12, 2021
I want to display a meta description in the Header Element.
I guess I will have to create and add shortcode, what code should I add?
I use SEOPress to add the post meta description.
Hi there,
Just to confirm, you are trying to display the content added in SEOPress?
If so have you checked with their support team to see if they are able to help with the code you need?
Post meta description isn't a default WordPress element.
It would be helpful if I could customize it like the topic below.
Sorry not sure if I fully understand.
What is the issue when you use the solution in that thread?
add_shortcode( 'page_hero_meta_desc', function() {
if ( class_exists( 'WPSEO_Frontend' ) ) {
$wpseo_object = WPSEO_Frontend::get_instance();
$intro_text = $wpseo_object->metadesc( false );
return $intro_text;
}
} );
The above code will not display the meta description.
Is it possible to customize the code for SEOPress?
Or is it possible to display an excerpt instead of a meta description?
Hi there,
you would have to ask SEO Press what code can be used to output their meta description.
For the Post Excerpt - see the example Leo provides here:
https://generatepress.com/forums/topic/change-excerpt-length-and-source/#post-1604129
The above topic solved the problem for me, thank you!
I'm getting "READ MORE" with the specified maximum number of characters, how can I display the full text of the excerpt?
Can you open a new topic for a separate question?
Thanks :)