2012-03-30 101 views

回答

1

编辑你的主题

/wp-content/themes/your-theme-name/loop.php 

找帖子链接如...

<a href="<?php the_permalink(); ?>" class="read_more_link" ><?php echo __('Read more &raquo;' 

add target="_blank"属性

<a href="<?php the_permalink(); ?>" target="_blank" class="read_more_link" ><?php echo __(

每个WordPress主题都有不同的html。只搜索.. href="<?php the_permalink(); ?>"这是每篇文章的固定链接

+0

谢谢你我的主题没有loop.php,但the_permalink()是在index.php,所以我刚刚添加目标和它的工作正常。谢谢 – 2012-03-30 04:42:10

1

打开您的相关php文件,即。 front-page.php,home.php ...只需在标题<a>中加上target="_blank"即可。

-1

除非你对自己收留了它,我不认为你可以,否则只是改变你的链接:

<a href="your url" target="_blank">blah</a> 
+0

你需要编辑的文件将是**的wp-content /主题/ YOUR_THEME /环page.php文件**我想。它将成为这些循环页面之一。 – 2012-03-30 04:27:36

5

在Wordpress中,每个主题都有不同的模板。

尝试寻找

< a href="<?php the_permalink(); ?>"...............><?php the_title(); ?></a>  

F3并搜索这些代码就像the_title();。 通常,这些类型的代码是建立在模板中像

的single.php,content.php,loop.php,内容的single.php

只是在代码中添加target="_blank"

例如:

<a href="<?php the_permalink(); ?>" target="_blank".....><?php the_title(); ?></a> 
0
I found this code on http://www.wpcodesnippet.com/open-external-links-new-window/ and it worked like a charm for me. Just add it to your footer.php. 

<script type="text/javascript"> 
     //<![CDATA[ 
     jQuery(document).ready(function($) { 
      $('a').each(function() { 
       var a = new RegExp('/' + window.location.host + '/'); 
       if(!a.test(this.href)) { 
        $(this).click(function(event) { 
         event.preventDefault(); 
         event.stopPropagation(); 
         window.open(this.href, '_blank'); 
        }); 
       } 
      }); 
     }); 
     //]]> 
    </script> 
+1

嘿!你能否更新你的答案以包含你的链接中的相关代码?如果该链接在未来中断,您的答案将变得毫无用处。请参阅http://stackoverflow.com/help/how-to-answer上的**为链接**提供上下文 – 2015-09-17 22:48:39