Support » Fixing WordPress » Open post type in new tab to edit it in WordPress

  • Resolved brukevin

    (@brukevin)


    Hello

    Is it possible to add an attr target=”_blank” to post list in wordpress dashboard. Or a solution to open on click a post type (form the list) to a new tab to edit it ?

    at the moment I have this :

    add_action(‘admin_head-edit.php’, ‘wpse152971_edit_post_change_title_in_list’);

    function wpse152971_edit_post_change_title_in_list() {
    add_filter(‘the_title’, ‘wpse152971_construct_new_title’, 10, 2);
    }

    function wpse152971_construct_new_title($title, $id) {
    //print_r(title);
    return $title;
    }
    but I just hit the title and not the entire post link tag.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Ian

    (@plantprogrammer)

    Hi, brukevin, if you’re interested in modifying the post actions i.e. the edit button from the edit,quick edit,trash,view etc options, I would take a look at the post_row_actions filter.

    Here is some sample code I created that adds a new option to edit the post from a new tab:

    add_filter( 'post_row_actions', 'tab_row_actions', 10, 2 );
    function tab_row_actions( $actions, $post )
    {
        if( get_post_type() === 'post' )
    	{
    		$edit_tag = "<a target='_blank' href='";
    		$link = admin_url( 'post.php' );
    		$edit_tag .= add_query_arg(array('post' => $post->ID, 'action' => 'edit'), $link);
    		$edit_tag .= "'>Edit in New Tab</a>";
    		$actions['edit_new_tab'] = $edit_tag;
    	}
        return $actions;
    }

    If you want to edit the post titles themselves, I would take a look at this topic from StackOverflow and edit it to fit your needs:
    https://wordpress.stackexchange.com/a/248408/190079

    brukevin

    (@brukevin)

    Thank you !

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.