如何在新标签页/窗口中打开每个Wordpress帖子?

时间:2012-03-30 04:11:41

标签: php html wordpress

我有一个wordpress博客,其主页显示了10个最新帖子的列表。

现在每当我要点击任何帖子标题时,新帖子都会在同一个标​​签中打开,但在这里我想让它在新标签中打开。那么,我该怎么做呢?

6 个答案:

答案 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.phphome.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 &raquo;'

添加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)

一个方便的解决方法是,在通知页面更新后,将横幅设置为在页面上打开新标签页:页面已更新。 查看页面链接。在text editor view with added text highlighted

答案 5 :(得分:-1)

除非您自己托管,否则我认为您无法托管,否则只需将您的链接更改为:

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