I have this code in author.php
file
echo $part_cur_auth_obj->description;
How can i parse the echo so the links within the author description will have the rel="nofollow"
attribute set automatically?
If you want to add rel="nofollow" to all the links, then you can simply use str_replace():
echo str_replace(
'<a href=',
'<a rel="nofollow" href=',
$part_cur_auth_obj->description
);
You can do this simply by javascript code, Add this to your footer.php
file this will add attribute to all tags.
$( document ).ready(function() {
$('body > a').attr('rel','nofollow')
});
Or can be done by using ID's for particular tags
$( document ).ready(function() {
$('body > a#ID_OF_A_TAG').attr('rel','nofollow')
});
make sure you have pasted correct ID of <a id="MY_ID">
tag. MY_ID in this case
You can always benefit from pre-defined WordPress functions, see wp_rel_nofollow
echo wp_rel_nofollow($part_cur_auth_obj->description);
print_r($part_cur_auth_obj->description)
first and share with me the output.