How to change the URL of the edit post link?

I want to change the URL of the edit post link so that it directs you to my own custom edit page. I’ve been looking for a filter or function but all I can find is the edit_post_link() function and the get_edit_post_link() function. From what I can see from documentation, edit_post_link only changes the links text, not the URL. And get_edit_post_link I believe gets the URL for you.

Related posts

Leave a Reply

3 comments

  1. You would need to add a filter to get_edit_post_link. This is untested, but something like:

    add_filter( 'get_edit_post_link', 'my_edit_post_link' );
    function my_edit_post_link( $url, $post->ID, $context) {
        $url = //However you want to generate your link
    
        return $url;
    }
    
  2. Working version:

    add_filter( 'get_edit_post_link', 'my_edit_post_link', 10, 3 );
    function my_edit_post_link( $url, $post_id, $context) {
        $url = "http://somethingerother.com/custom_post_editor.php?post=".$post_id; // Modify the URL as desired
    
        return $url;
    }
    
  3. my wordpress dev skills are a little rusted but you should probably use wordpress hooks to hook edit_post , and write your plugin to rewrite the return value or do_action to just go yo your own custion edit page