Issue-1:
edit_post_link()
is a template function, to be used in theme template files. It’s not used in the Admin pages. So you’ll not get the edit_post_link
filter hook for the Admin list pages.
Issue-2:
get_edit_post_link()
function however, is used in Admin list pages. So you’ll get the get_edit_post_link
filter hook for the Admin list pages.
Issue-3:
Even though you’ll get the get_edit_post_link
filter hook for the Admin list pages, it is used mainly for the link itself, not the entire <a>
tag. So you can’t change <a href="Edit-link">
to <a href="Edit-link" target="_blank">
. WordPress core doesn’t allow that.
Check the core CODE here, it doesn’t allow target="_blank"
:
printf(
'<a class="row-title" href="%s" aria-label="%s">%s%s</a>',
get_edit_post_link( $post->ID ),
/* translators: %s: Post title. */
esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) ),
$pad,
$title
);
Possible solution:
You can still alter this behaviour by hooking into wp_list_table_class_name
filter hook and extend the WP_Posts_List_Table
class with something like WP_Custom_Posts_List_Table
to override the column_title()
function to achieve target="_blank"
for your specific custom post type.
It’s probably a lot of work only for opening a link in a new tab, but I don’t see any other proper alternative implementation. Easier JavaScript implementation is possible, but that’s more of a hacky solution.