WordPress.org

Support

Support » How-To and Troubleshooting » echo the excerpt without p tags around

echo the excerpt without p tags around

  • I would like to use the excerpt for
    meta description for single articles

    but if I’m using php echo the excerpt there are the p html tags around the text and html tags between
    head and /head are very crazy 😉

    is their a way to ‘delete’ this html tags.

    thanks
    Monika

Viewing 1 replies (of 1 total)
  • Try the_excerpt_rss() like this:

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

    It strips the <p> tags but doesn’t seem to strip others. For example I had an <abbr> make it through which kind of messed things up a little.

    Of course, you’ll want to put a conditional statement in there to only use the post excerpts for single post pages. Otherwise the first text (usually from the first post) will get posted as the description of your homepage.

    Edited for clarity.

Viewing 1 replies (of 1 total)
  • The topic ‘echo the excerpt without p tags around’ is closed to new replies.
Skip to toolbar