Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Excerpt as meta description

  • Hi,

    I just saw an old post https://generatepress.com/forums/topic/using-excerpt-as-meta-description/#post-977934 which does exactly what I want, except that it displays the meta description as a paragraph.

    The hook element is:

    <meta name="description" content="<?php echo the_excerpt(); ?>" />

    which displays as:

    <meta name="description" content="<p>Let’s embark on your journey through one of Japan’s best-kept secrets and unlock a treasure trove of activities. This in-depth guide will ensure you don’t miss a beat in Kobe, capturing the essence of the Tiger City that captivates thousands each year.</p>
    " />		

    Is there an easy fix to get rid of the <p> and </p>?

    Thank you.

  • Hi there,

    try this:

    <meta name="description" content="<?php echo strip_tags(get_the_excerpt()); ?>" />

  • Works beautifully, thanks again!

  • You’re welcome

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