How to change the title url on the edit post screen?

I searched in various places and am battling to find the correct place or terms used for the following.

I am only using posts as an example.

When you view all posts in wp-admin you get the title of the post and below it the Edit, Quick Edit, Trash and Preview links. By using the post_row_actions action hook I can change the links below the title but not the link on the title itself.

Are there an alternate way to change the link on the post title to open a different url? or can I change it with the same hook?

I am developing front-end content management screen and want to point all edit links to point to the front of the website.

Many thanks :)

Topic row-actions wp-admin posts Wordpress

Category Web


I am developing front-end content management screen and want to point all edit links to point to the front of the website.

If you want to point all edit links to the FE, you should go for the get_edit_post_link filter solution (see Marko's answer). That will cover all cases where either the core or a plugin calls get_edit_post_link().

But if you want to implement "proper" front-end content management, you should go beyond that. I've seen plugins that bypass the API and hardcode the edit post url calculation. Moreover, there's always a chance that a user could type the admin url and land on the default edit post admin screen.

So I think you should redirect the default post edit url to your frontend:

add_action(
    'admin_init',
    function()
        {
        global $pagenow;
        if($pagenow=='post.php'
          && isset($_GET['action']) && $_GET['action']=='edit'
          && isset($_GET['post']))
            {
            $post_id=$_GET['post'];
            // calculate $fe_edit_screen using $post_id
            wp_redirect($fe_edit_screen);
            exit;
            }
        },
    1
    );

This way, everyone will be redirected to your frontend, no matter how they ended up accessing the post edit screen. Moreover, you could add more checks, in case for example you want to redirect only users that have (or don't have) specific capabilities, or only for certain post types, or whatever.


Use get_edit_post_link filter.

add_filter('get_edit_post_link', 'get_edit_post_link_178416', 99, 3);

function get_edit_post_link_178416($link, $post_id, $context) {
    $scr = get_current_screen();

    if ($scr->id == 'edit-post' && $context == 'display') {
        return 'http://google.com';
    } else {
        return $link;
    }
}

You can see it's used here

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.