Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

In the code snippet below, I trying to get the_excerpt to be written out without tags. However, the source formatting shows that the_excerpt is always wrapped in P tags. How can I pull the excerpt without tags?

foreach($myrecentposts as  $idxrecent=>$post) 
{ ?>
<li class="page_item">
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    <?php echo strip_tags(substr( the_excerpt(), 0, 75 ))."..." ?>
</li><?php }    
echo "</ul>
</div>";}
share|improve this question

2 Answers 2

up vote 2 down vote accepted

in your code above use get_the_excerpt() instead of the_excerpt(), because the last one will output the excerpt to the screen, and not pass it to your other functions...

share|improve this answer
    
Perfect! Thanks for your help AA –  Scott B Jan 13 '11 at 22:11

What about removing the wpautop filter before your list?

remove_filter( 'the_excerpt', 'wpautop' );

(Make sure to add it back afterwards, so as not to mess up other formatting...)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.