stripping tags from excerpt in Wordpress is not working

user1770896 picture user1770896 · Jul 31, 2013 · Viewed 11.3k times · Source

I am using this snippet

<a href='<?php the_permalink() ?>' title='<?php echo strip_tags(the_excerpt()); ?>

with which I am intending to remove all ellipses, <p> tags and other shortcodes and links, but that does not work at all.

If I hover the anchor, I am still getting to see the <p> wrapped in the excerpt, as well as other tags and the url links. What am I doing wrong and what do I have to do to get it working?

Answer

Johan picture Johan · Jul 31, 2013

What you need is get_the_excerpt():

<a href='<?php the_permalink() ?>' title='<?php echo strip_tags( get_the_excerpt() ); ?>'>

However, it probably won't strip out ellipses (…) since they're HTML entities, not tags.