Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Automatically add hyperlinks to comments WordPress

  • SOLVED

I'd like to automatically add hyperlinks to comments that people leave on my posts. For example: http://interactiveblend.com/blog/creative/rebound-and-win-a-dribbble-invite

Is there a setting to turn of or something I can add to functions.php?

Answers (3)

2011-03-04

Sébastien | French WordpressDesigner answers:

i don't understand what you want...


Louis Gubitosi comments:

for example, someone added text : http://cl.ly/0A2M1v3T163o3A0S4709 but it is not linking. Instead of having to copy the text into my broswer, can I make this an active link?


Sébastien | French WordpressDesigner comments:

it's automatic


Louis Gubitosi comments:

not on my site...


Sébastien | French WordpressDesigner comments:

if you type http://toto.com in the textarea of comment, you have an active link in the publish comment


Sébastien | French WordpressDesigner comments:

that's your site : http://interactiveblend.com/blog/creative/rebound-and-win-a-dribbble-invite


Sébastien | French WordpressDesigner comments:

in the code of oleg, replace
function get_comment_text($comment)
by
function get_comment_text_custom($comment)


Sébastien | French WordpressDesigner comments:

So. I have install the theme "minimalism" on my site
is it right your theme ? : http://wordpress.org/extend/themes/minimalism

I have install and activate your plugins :
wp-paginate
wp-thumbie
wp-dribble

Have you actiavte others plugins ?

I have no trouble with the links in my comment area.

So, i thing you have customize your theme. I see a field "twitter" in your comment. How have you integrate this field ?
Could you eventually send me your theme folder and your plugin folder please, and i install all that on my site for testing
maildeseb @ gmail .com


Sébastien | French WordpressDesigner comments:

URL of my test with your theme and plugins : [[LINK href="http://demo2.archiparmentier.com/categorie-1/a-la-une#comment-8"]]http://demo2.archiparmentier.com/categorie-1/a-la-une#comment-8[[/LINK]]

2011-03-04

Oleg Butuzov answers:

You mean twitter urls like at example?


Louis Gubitosi comments:

for example, someone added text : http://cl.ly/0A2M1v3T163o3A0S4709 but it is not linking. Instead of having to copy the text into my broswer, can I make this an active link?


Oleg Butuzov comments:



add_filter('get_comment_text', 'get_comment_text_custom');

function get_comment_text($comment){
if (preg_match_all("/http:\/\/(.*?) /si", $comment.' ', $matches)){
foreach($matches[0] as $k=>$i){
$comment = str_replace($i, '<a href="'.$i.'">'.$i.'</a>', $comment);
}
}
return $comment;
}



into your functions.php (simple example)


Louis Gubitosi comments:

thanks, but that was breaking my site...


Oleg Butuzov comments:

what's the error?


Louis Gubitosi comments:


Fatal error: Cannot redeclare get_comment_text() (previously declared in /home/content/32/3864832/html/blog/wp-includes/comment-template.php:598) in /home/content/32/3864832/html/blog/wp-content/themes/minimalism/functions.php on line 29


Oleg Butuzov comments:

just rename my function from get_comment_text to get_comment_text_custom


Louis Gubitosi comments:

didnt kill the site, but new error: Fatal error: Call to undefined function my_get_avatar_filter() in /home/content/32/3864832/html/blog/wp-content/themes/minimalism/comments.php on line 36


Oleg Butuzov comments:

sorry man this isn't my function.... my_get_avatar_filter -relates to some external avatar function...


add_filter('get_comment_text', 'get_comment_text_custom');



function get_comment_text_custom($comment){

if (preg_match_all("/http:\/\/(.*?) /si", $comment.' ', $matches)){

foreach($matches[0] as $k=>$i){

$comment = str_replace($i, '<a href="'.$i.'">'.$i.'</a>', $comment);

}

}

return $comment;

}


Louis Gubitosi comments:

thanks, no error this time but the links aren't there: http://interactiveblend.com/blog/creative/rebound-and-win-a-dribbble-invite


Oleg Butuzov comments:

i did test function before post, sorry. its alreay cost 4$.

i think the comment shown without default filter. why? have no idea.. its can be also shown as $comment->comment_text; intested comment_text();...

but the function isn't working, nothing triggering it... if you want me to change the install it and chack whats wrong, increase a prize and provide access to the server.

2011-03-05

Nilesh shiragave answers:

Open your themes functions.php file and add following code inside that file at the end just before closing ?> php tag

add_filter( 'comment_text', 'make_clickable',9 );


Louis Gubitosi comments:

thanks but that didnt do the trick...