How to get url of a post from admin panel

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.

Read More

Looking for this answer:

 global $post;
 get_permalink($post->ID);

thx all

Related posts

3 comments

  1. You can get the ID of the post you’re editing like this:

    //currently edited post id 
    $cep_id = $_GET['post'];
    //permalink
    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.

  2. 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';
    

Comments are closed.