0

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?

3
<?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:

  • 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 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.