Genel en

Opening WordPress Comment Links in New Tab / Window

WordPress’s comment feature is the best way to interact with users. Comments are why users are more interested in a blog. Most of the time, there are high quality discussions through comments. So if you have a wordpres blog, it is very important for the site to be brand.

However, one of the problems with comments is that all links (URLs) in the comments have been opened in the same tab. This removes the audience from your site and increases the bounce rate. Here is the solution to this problem. Open all comments in WordPress in a new tab or window.

Add target = ”_ blank target to comment links

target = “blank” We can open them in a new window by adding them to the comment links and the author URL. To do this, we’ll add filters to two WordPress hooks – get_comment_author_link and comment_text.

Method 1: Use Theme

You can add the following code to the functions.php file of the theme. Be sure not to add any other functions.

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

Method 2: Attachment

The above method has the disadvantage. When you update your theme, you lose all the code you added. But if you turn it into a plugin, you can use it forever.

To create an add-in, first create a new folder in WP-content -> lugins. Let’s call it el comments-new-tab-acmak-. Then create a new PHP file – say in comment-links-in-new-tab.php PHP.
(You can give the folder and file any name. Make sure that name is unique.)

All links in the comments and author URL will now open in the new tab.

Önerilen Yazı →   WordPress Alan Adı Değişikliği

Buğra Yazar

Startup WordPress Kurucusu. 2010 yılından bu yana çeşitli web projelerinde yer aldım. Kendimi SEO, WordPress Sosyal Medya ve Dijital Pazarlama alanlarında geliştirdim ve geliştirmeye devam ediyorum. SEO Uzmanı olarak Arama motoru optimizasyonu ve Dijital Pazarlama konularında hizmet vermekteyim. Bildiklerimi blogumda paylaşıyorum.

Benzer Yazılar

Bir Yorum

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Başa dön tuşu