Remove <P> from excerpt ?

Discussion in 'WordPress' started by Audiomad, Apr 12, 2012.

  1. #1
    I'm trying to get the excerpt to work as my page description it's working just fine apart from the <p></p> showing in the text, I want to have the page description done this way as it will speed up adding content and if any others forget to enter a description it will still work.

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <meta name="description" content="<?php the_excerpt(); ?>" />
    <?php endwhile; else: ?>
    <?php endif; ?>
    Code (markup):
     
    Audiomad, Apr 12, 2012 IP
  2. 5Twenty

    5Twenty Peon

    Messages:
    79
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    We actually did a blog post on several different ways to do this, which you can find here: http://redrokk.com/2010/08/16/removing-p-tags-in-wordpress/

    In this case the easiest way is to simple place <div>t ags around it. This will prevent WP form adding p tags because it already has a block in place.

    BTW: The code you have as an example has nothing to do with it. WP adding p tags is built into the core of Wordpress not the template files. You can also find plugins that will remove these for you on the Repo or maybe CodeCongo.com
     
    5Twenty, Apr 12, 2012 IP