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.

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

1 Answer 1

up vote 3 down vote accepted
<?php
    // 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);
?>

Reference:

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

 
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.