• Resolved comeng

    (@comeng)


    Hi,

    Posts in Sidebar plugin enables us to link the title to the post but it opens the link in the same screen. Is there any way to open the post links in new tabs?

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Aldo Latino

    (@aldolat)

    Hi,
    this option is not included because it’s very uncommon to open links to the current website in another tab of the browser.

    Anyway, you can use jQuery to do this. It’s not so difficult to do. If you are comfortable with editing and creating files of a WordPress theme, please let me know and I’ll tell you all the few steps to do this. ??

    Thread Starter comeng

    (@comeng)

    Hi Aldo,

    First of all, your plugin is awesome. ??

    I can edit or create any file you desire. But I think a new update of the theme will override this change. I’ll be waiting for your steps to do this, though.

    Thanks.

    Plugin Author Aldo Latino

    (@aldolat)

    Hi,

    First of all, your plugin is awesome.

    Thank you! ??

    I can edit or create any file you desire. But I think a new update of the theme will override this change. I’ll be waiting for your steps to do this, though.

    You’re right. For this reason I recommend using a child theme (if you’re not using a custom theme) or a functionality plugin.

    If you decide to use a child theme and after you have created and activated the child theme, here the steps to add the modification for Posts in Sidebar:

    1) Inside your child theme directory create a directory named scripts.

    2) Inside this new directory, create a new file named pis-hacks.js and paste this content:

    jQuery(document).ready(function(){
    	jQuery('a.pis-title-link').attr('target','_blank');
    });

    Save the file.

    3) Open the file functions.php of your child theme and paste these lines at the end of the file:

    function posts_in_sidebar_hacks() {
    	wp_register_script(
    		'pis_scripts',
    		get_stylesheet_directory_uri() . '/scripts/pis-hacks.js',
    		array( 'jquery' ),
    		'1.0.0',
    		true
    	);
    
    	wp_enqueue_script( 'pis_scripts' );
    }
    add_action( 'wp_enqueue_scripts', 'posts_in_sidebar_hacks' );

    Make sure to paste these lines before the closing PHP tag ?>, if present.

    Save the file and test the result.

    Please, let me know.

    Thread Starter comeng

    (@comeng)

    Hi,

    It works. Though, it would be better if it is applied in a configurable way from the plugin settings.

    Thanks.

    • This reply was modified 4 years, 10 months ago by comeng.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Posts In New tab’ is closed to new replies.