1

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

  • That could work because WordPress basically uses jQuery for almost everything. I am using a temp solution for now: (TITLE still points to back-end but I am actively looking for a solution and will definitely try the jQuery idea out) Front Edit | Quick Edit | Trash | Preview – Kobus Beets Feb 17 '15 at 13:22
  • Glad that helped :) I'll delete my comment from above and post it as an answer. – cristian.raiber Feb 17 '15 at 13:23
7

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

  • That is a perfect answer to my question. Thank you Marko Jakić. I can use the $post_id as leverage to point to different front-end URL's. – Kobus Beets Feb 18 '15 at 6:28
1

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.

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.