Notifications
Clear all

wpForo 1.x.x [Closed] Links to open in new tab

10 Posts
5 Users
2 Likes
1,000 Views
StocksForum
Posts: 135
Topic starter
(@stocksforum)
Estimable Member
Joined: 5 years ago

How can I make links open in a new tab rather than in the current window which then takes me out of the forum?

The links in here for example:

https://smallcaps.com.au/forum/technology/emerge-gaming-to-develop-nickelodeon-esports-gaming-platform/

9 Replies
Sofy
Posts: 4140
 Sofy
Admin
(@sofy)
Support Team
Joined: 6 years ago

Hi @stocksforum,

try the following js code. Add it in your theme js files:

jQuery(".wpforo-post-content a").attr('target' ,'_blank');
4 Replies
StocksForum
(@stocksforum)
Joined: 5 years ago

Estimable Member
Posts: 135

Ok, can it be added in the future wpForo update?
Seems logical, otherwise people are taken away from the forum and may not return.

Sofy
 Sofy
Admin
(@sofy)
Joined: 6 years ago

Support Team
Posts: 4140

We'll take this into consideration for future updates.  

(@hector)
Joined: 5 years ago

Estimable Member
Posts: 108
Posted by: @sofy

Hi @stocksforum,

try the following js code. Add it in your theme js files:

jQuery(".wpforo-post-content a").attr('target' ,'_blank');

Exactly in which file and where do I have to put that JavaScript code?

 

Sofy
 Sofy
Admin
(@sofy)
Joined: 6 years ago

Support Team
Posts: 4140

@hector,

I'd suggest you read this article: https://www.collectiveray.com/add-javascript-to-wordpress

VereK
Posts: 482
(@verek)
Honorable Member
Joined: 6 years ago

Aside from the code above, if links are pasted as plain text (control+shift+v) it will auto add the target_blank functions.

Straight paste: https://wpforo.com/community/how-to-and-troubleshooting-2/links-to-open-in-new-tab/#post-27897

Plain text paste: https://wpforo.com/community/how-to-and-troubleshooting-2/links-to-open-in-new-tab/#post-27897

3 Replies
StocksForum
(@stocksforum)
Joined: 5 years ago

Estimable Member
Posts: 135

Thanks.

However need it to operate universally to open in new tab.

As users of the forum just want it to be simple to use and I want to make sure they stay in the forum when clicking a link, not ending up on another site.

(@anonymous20)
Joined: 8 years ago

Noble Member
Posts: 1602
Posted by: StocksForum

Thanks.

However need it to operate universally to open in new tab.

As users of the forum just want it to be simple to use and I want to make sure they stay in the forum when clicking a link, not ending up on another site.

Why don't you try a Wordpress plugin for that. There are plenty.

StocksForum
(@stocksforum)
Joined: 5 years ago

Estimable Member
Posts: 135

No thanks. I run a news site with many other features in it, the forum is just a part of it, most of the links are internal and open in the window.
Also adding plugins can slow the site and cause conflicts, plus security issues.

Links in the forum, especially if they are an external url, should open in a new tab logically. Thus keeping people in the forum.