[Resolved] Yoast Meta Description as Excerpt below Post Title

Home Forums Support [Resolved] Yoast Meta Description as Excerpt below Post Title

Home Forums Support Yoast Meta Description as Excerpt below Post Title

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #1513347
    Chitika

    I write my meta description using Yoast Plugin.
    There are about 400 posts.
    Now I want to display this meta information below post title, just like branded sites.

    Is it possible?

    #1513512
    David
    Staff
    Customer Support

    Hi there,

    you can display the yoast meta description using this PHP snippet:

    <?php echo get_post_meta(get_the_ID(), '_yoast_wpseo_metadesc', true); ?>

    You can use a Hook Element to add that meta where you require it:

    https://docs.generatepress.com/article/hooks-element-overview/

    #1522149
    Chitika

    How to display it after post title.

    Also I would like it to be H3 Tag with some color coding.

    #1522619
    David
    Staff
    Customer Support

    You would use the generate_after_entry_title Hook with a priority of 5
    You can see all hooks here:

    https://docs.generatepress.com/article/hooks-visual-guide/

    Changing it to H3 you could try this instead:

    <?php echo '<h3>' . get_post_meta(get_the_ID(), '_yoast_wpseo_metadesc', true) . '</h3>'; ?>

    Not sure it will work correctly but that as much as we can do as we’re not in control of Yoasts shortcode.

    #1523197
    Chitika

    You would use the generate_after_entry_title Hook with a priority of 5

    I have used the above location. But it displays before post title or after breadcrumbs. I even made the priority of 3. Same result.

    #1523412
    David
    Staff
    Customer Support

    How have you added the description text into the Entry Header ?

    #1523691
    Chitika

    Frankly I didn’t understand your question.

    I added the raw code you gave me.

    View post on imgur.com

    #1523693
    Chitika
    #1523713
    David
    Staff
    Customer Support

    See here:

    Your site has content being displayed before the Post Title – this is not a standard function of the theme. So how did you add this Content ?

    #1523716
    Chitika

    Actually that is the “Yoast Meta Description” as you suggested with generate_after_entry_title hook.

    #1523721
    Chitika

    BTW, I’m also using Yoast Breadcrumbs code to display using generate_before_content hook.

    #1523725
    David
    Staff
    Customer Support

    You have this CSS:

    .entry-header {
        display: flex;
        flex-direction: column-reverse;
    }

    Delete that and it will return the order to below the title.

    #1523799
    Chitika

    I have deleted it. But it still shows about title.
    I have cleared all the cache too.

    #1523954
    David
    Staff
    Customer Support

    I can still the CSS on your site – can you clear your plugin/server caches ?

    #1524775
    Chitika

    Thanks @David. It seems the Varnish and Cloudflare cache are taking some time to clear.
    Now I see the changes. Also, I tried to make the color of the meta to Red and it works.
    So probably the <h3> tag also should work.

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.