How to get url of a post from admin panel

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.

Leave a Comment