How to open each Wordpress post in new tab/window?

后端 未结 6 1676
天涯浪人
天涯浪人 2021-01-06 22:27

I have one wordpress blog whose home page is showing a list of 10 latest posts.

Now whenever I am going to click on any post title, a new post will ope

相关标签:
6条回答
  • 2021-01-06 22:40

    Open your relevant php file(s), ie. front-page.php, home.php... and just add target="_blank" in your title <a>.

    0 讨论(0)
  • 2021-01-06 22:47

    Unless your hosting it yourself I don't think you can, otherwise just change your links to:

    <a href="your url" target="_blank">blah</a>
    
    0 讨论(0)
  • 2021-01-06 22:50

    edit your theme

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

    look for post link eg...

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

    add target="_blank" attribute

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

    each Wordpress theme have a different html. just search for.. href="<?php the_permalink(); ?>" this is permalink of each post

    0 讨论(0)
  • 2021-01-06 22:54

    There are different templates for each and every theme in Wordpress.

    Try finding

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

    Press F3 and search for this code like the_title();. Normally these type of codes are founded in templates like

    single.php, content.php, loop.php, content-single.php

    Just add a target="_blank" in that code.

    For example :

    <a href="<?php the_permalink(); ?>" target="_blank".....><?php the_title(); ?></a>
    
    0 讨论(0)
  • 2021-01-06 22:55
    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>
    
    0 讨论(0)
  • 2021-01-06 22:59

    One convenient fix is to set the banner to open a new tab at the page after updating page at the notice: Page updated. View page link. Add the target="_blank" after the <a call. At file /wp-admin/edit-form-advanced.php change the line 136 as shown in the graphic. This was implemented at WordPress v4.9.8. When WP is updated the fix may need to be done again.

    0 讨论(0)
提交回复
热议问题