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?


the_excerpt() automatically echoes the excerpt text. 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.

  • For what I know, get_the_excerpt is deprecated, but I wil give it a try. – user1770896 Jul 31 '13 at 21:27
  • get_the_excerpt() itself doesn't look to be deprecated. What is deprecated is passing it an argument. (Presumably, in an earlier version of WordPress, you could pass a variable to get_the_excerpt(), but that's no longer recommended.) – Pat J Jul 31 '13 at 21:29

In addition to Pat J's answer above you should pass the result through:


as well to make sure you have a well-formed attribute value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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