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>";}
in your code above use
get_the_excerpt()
instead ofthe_excerpt()
, because the last one will output the excerpt to the screen, and not pass it to your other functions…What about removing the
wpautop
filter before your list?(Make sure to add it back afterwards, so as not to mess up other formatting…)
I tried the above answers but didn’t work for me.
I tried using the_excerpt but wasn’t displaying any content so I used the below and it worked perfectly
I hope this throws more light for someone else too.
Cheers
<?php echo strip_tags(get_the_excerpt()); ?>
this worked for mesorry for this => Body must be at least 30 characters; you entered 18.
Below did the trick using ACF plugin: