wpDiscuz - WordPress Comment Plugin
Feature Request - o...
 
Share:
Notifications
Clear all

[Solved] Feature Request - open comment URLs in new tab


wpUser
Posts: 21
Topic starter
(@wpuser)
Eminent Member
Joined: 1 year ago

Hi Gvectors,

In a future update, could we please have the option for comment links to be opened in a new tab or window? I've searched these forums and have seen solutions that require js code or changing the functions.php file. The problem with this is that there's a concern, particularly among non-developers, that it could break our site if we do it incorrectly. 

A simple toggle that you can switch on/off would be great!

Thanks!

2 Replies
Asti
Posts: 3567
 Asti
Support
(@asti)
Support member
Joined: 4 years ago

Hi @wpuser,

I may suggest you check out the solution provided in this support topic: https://wpdiscuz.com/community/postid/3646/

If you don't want to use some other plugin, you can use the following code:

function t4a_comment_links_in_new_window($text) {
    return str_replace('<a', '<a target="_blank"', $text);
}
add_filter('comment_text', 't4a_comment_links_in_new_window');

Add the following code to your functions.php of your theme. Here is a helpful article: https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/

 

1 Reply
wpUser
(@wpuser)
Joined: 1 year ago

Eminent Member
Posts: 21

Thanks! Will try this.

Share: