Is there a way to have the view link on manage posts page to open in a new window or tab?

Hi I am trying to figure out on how to get the “view” link on the manage posts / custom post types and pages to open in a new tab or window.

A screenshot of what I am talking about.

Read More

I know it is probably possible to do via the functions.php file of the theme and would much rather go that route than using a plugin.

Any help with this would be appreciated. Thank you. 🙂

Related posts

Leave a Reply

2 comments

  1. Late answer

    WP core offers a function for that case, that makes it much easier and future proof: Simply map it on each item.

    Wrapped up in a plugin

    Best used as mu-plugin.

    <?php 
    /* Plugin Name: (#32093) »kaiser« Open "action"-links in post type list screens in new windows/tabs */
    
    function wpse32093_link_target_blank( $actions, $post )
    {
        return array_map( 'links_add_target', $actions );
    }
    // Add to each post type
    foreach ( array( 'post', 'page' ) as $post_type )
        add_action( "{$post_type}_row_actions", 'wpse32093_link_target_blank', 20, 2 );
    

    The plugin is tested and works seamlessly. You can adjust the post types where you want to have it active in the array inside the foreach loop.

  2. <?php
    /*
    Plugin Name: [Editor] Popup View
    Author URI: http://www.earnestodev.com/
    Description: Opens View link in new windows for in posts and pages manager.
    Author: EarnestoDev
    Version: 5.U.B
    Author URI: http://www.earnestodev.com/
    */
    // ----------------------------------------------------------------- //
    function popup_view_row_action($actions, $post){
        // Walk array with value references for easy changing
        if(is_array($actions)) foreach($actions as $key => &$value){
            // For the right row_action
            if(($key === 'view') and is_string($value)){
                // Add the target="_blank" in the A tag's attributes
                $value = preg_replace('~<a[s]+~i', '<a target="_blank" ', $value);
            }
        }
        return $actions;
    }
    // ----------------------------------------------------------------- //
    // Hooks both hierarchical and non-hierarchical
    add_action('page_row_actions', 'popup_view_row_action', 11, 2);
    add_action('post_row_actions', 'popup_view_row_action', 11, 2);
    // ----------------------------------------------------------------- //
    ?>
    

    Place in a file here /wp-contents/mu-plugins/popup-view-action.php or here /wp-contents/plugins/pupup-view-action.php and then activate.

    Regards.