Site logo

Archived topic

Display meta description in the Header Element

7 replies · Started by Takeru on February 12, 2021

Viewing posts 1–8 of 8

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.

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?

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 :)

This archived topic is closed to new replies.