I want to get post url from the back end edit post page, the edit post url is : www.ddd.com/wp-admin/post.php?post=1&action=edit the real post is: www.ddd.com/wp/?p=1

since the user can edit permalink, i need some wordpress parametrs so it will be constant.

Looking for this answer:

 global $post;

thx all

  • 2
    Are you referring to the post url you see on admin edit screen or the url on the site frontend? Commented Dec 5, 2013 at 18:03
  • Can you add some more details on what you need and why so that we can look into the situation better and try and help you? Commented Dec 5, 2013 at 20:18

3 Answers 3


You can get the ID of the post you're editing like this:

//currently edited post id 
$cep_id = $_GET['post'];
get_permalink( $cep_id );

This is and can only work if your editing an existing/saved post. It won't and can't work on »Add New«-Pages, because the post you're going to add isn't saved to the database yet, after »Publish« has been pressed one gets redirected to the actual »Edit«-Page and the above is possible.

  • this what I looked for, thx
    – DrMosko
    Commented Dec 7, 2013 at 17:20

If you are looking for the post edit url for admin end and you have the post id (suppose $post_id) with you, then you can use the following code for getting the url.

$post_url = admin_url( 'post.php?post=' . $post_id ) . '&action=edit';

You can use the 'current_screen' hook and get_permalink():

add_action( 'current_screen', function ( $screen ) {
    $url = get_permalink( $screen->id );
    // ...
} );

This hook receives a WP_Screen_Object with misc. information about the current admin screen the user is browsing. See http://codex.wordpress.org/Plugin_API/Action_Reference/current_screen and http://codex.wordpress.org/Function_Reference/get_permalink for details.

  • get_permalink( $screen->id ) worked great
    – Ben
    Commented Nov 27, 2017 at 5:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.