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.

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. :)


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.

/* 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.

  • 1
    I really like the fluidity and flexibilty of what you have above. I will have to give it a try. Probably on this new project I am working on perhap. Thanks for your answer kaiser. Sometimes late is better than nothing. :) – Nicole Oct 2 '12 at 14:02
  • @Nicole You're welcome. Just stumbled upon links_add_target(), so I thought I drive by and spread the message :) – kaiser Oct 2 '12 at 16:55
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.


  • I know i said with out using a plugin but this is fairly light. I am always afraid of extremely heavy plugins to serve a very small purpose. I will give this a go. Thank you. :) – Nicole Oct 25 '11 at 18:12
  • @Nicole Copy it again! Forgot a PHP 5.3 only syntax inside that would make it probably not work with you. Sorry! It's become reflex to use the new PHP 5.3 syntax. Fixed it now for PHP 5.2 compatibility. – EarnestoDev Oct 25 '11 at 18:14
  • And you can't without a plugin. You can only alter WP functionality in the core or with a plugin. You can just hold Shift + Click to open in a new Window :) – EarnestoDev Oct 25 '11 at 18:15
  • 1
    yeah i know i can shift click to open new window or right click open in new tab. My thing is i am doing this for a client and was not sure how to go about doing this. :) Thanks again! – Nicole Oct 25 '11 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.