WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to clean any links returned from the_author_meta('description')

The code I use is simply that:

<p><?php the_author_meta('description'); ?></p>

I Searched old question but could not find the right anwer.. ideas anyone?

share|improve this question
up vote 3 down vote accepted
    // grab description,
    // note the "get_", we're not echoing the author meta, we're returning it
    $user_description = get_the_author_meta('description');
    // removing all HTML tags:
    echo strip_tags($user_description);
    // removing all tags apart from paragraphs:
    echo strip_tags($user_description,'<p>');
    // removing just anchors (i.e. <a> tags):
    echo preg_replace(array('{<a[^>]*>}','{</a>}'),array('',''),$user_description);
    // removing all links including their text (i.e. <a href="...">...</a>):
    echo preg_replace('{<a[^>]*>(.*?)</a>}','',$user_description);


share|improve this answer
I also tried strip_tags but it didnt work.. However preg_replace works like a charm :) thanks a lot man – Sagive SEO Nov 13 '11 at 5:15

Your Answer


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.