Support » Fixing WordPress » Removing <p> from the_excerpt

  • Resolved ajaskey


    I use the_excerpt() to create the description of individual posts.

    <?php if (is_single()) {
    echo (‘ <meta name=”description” content=”‘);
    echo (‘ “>’);
    elseif (is_page())

    Each description is enclosed in <p>…</p>. I want to remove this. Is there a function to send the output of the_excerpt through to remove html tags?

    Example of output:

    <meta name=”description” content=”<p>The Square of 90 is about to complete off the March low with price up over 40%.</p>


Viewing 3 replies - 1 through 3 (of 3 total)
  • Edward Caissie


    Theme Review Admin, The JellyBeen Man

    Admittedly my PHP skills are not the greatest but consider the code changes of using the PHP substr and strlen functions:

    <?php if (is_single()) {
    echo (' <meta name="description" content="');
    echo (' ">');
    elseif (is_page())

    Links to the PHP manual for reference, please validate code.

    cais – Thanks for the suggestion. I found that “the_excerpt_rss()” call does exactly what I want.

    Thank you ajaskey! I’ve been hunting around for a solution to this for days. Thanks for taking the time to follow up here with your solution.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Removing <p> from the_excerpt’ is closed to new replies.