我有一个wordpress
博客,其主页显示了10个最新帖子的列表。
现在每当我要点击任何帖子标题时,新帖子都会在同一个标签中打开,但在这里我想让它在新标签中打开。那么,我该怎么做呢?
答案 0 :(得分:5)
Wordpress中的每个主题都有不同的模板。
尝试查找
< a href="<?php the_permalink(); ?>"...............><?php the_title(); ?></a>
按 F3 并搜索此代码,例如the_title();
。
通常这些类型的代码建立在像
single.php,content.php,loop.php,content-single.php
只需在该代码中添加target="_blank"
。
例如:
<a href="<?php the_permalink(); ?>" target="_blank".....><?php the_title(); ?></a>
答案 1 :(得分:1)
打开相关的php
文件,即。 front-page.php
,home.php
...只需在标题target="_blank"
中添加<a>
。
答案 2 :(得分:1)
修改主题
/wp-content/themes/your-theme-name/loop.php
寻找帖子链接,例如......
<a href="<?php the_permalink(); ?>" class="read_more_link" ><?php echo __('Read more »'
添加target="_blank"
属性
<a href="<?php the_permalink(); ?>" target="_blank" class="read_more_link" ><?php echo __(
每个Wordpress主题都有不同的HTML。只搜索.. href="<?php the_permalink(); ?>"
这是每个帖子的永久链接
答案 3 :(得分: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>
答案 4 :(得分:0)
答案 5 :(得分:-1)
除非您自己托管,否则我认为您无法托管,否则只需将您的链接更改为:
<a href="your url" target="_blank">blah</a>