Support » Fixing WordPress » Removing <p> from the_excerpt

  • Resolved ajaskey

    (@ajaskey)


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

    <?php if (is_single()) {
    echo (‘ <meta name=”description” content=”‘);
    the_excerpt();
    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>

    Thanks.
    Andy

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

    (@cais)

    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="');
    substr(the_excerpt(),4,(strlen(the_excerpt)-4));
    echo (' ">');
    }
    elseif (is_page())

    Links to the PHP manual for reference, please validate code.
    http://ca.php.net/substr
    http://ca.php.net/manual/en/function.strlen.php

    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.