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.
Related Posts:
- How does WordPress create URLs that Apache knows about?
- Stop WordPress appending `-2` to the end of my url after i change it
- Get current URL (permalink) without /page/{pagenum}/
- How to get pretty URLs with add_query_arg in permalinks
- Creating custom permalink structure for languages
- Adding another word in front of post url
- ‘post_type_link’ filter not working
- Update URL Snippet to Canonical Permalink URL
- why does anchor name add a slash to url?
- How to create a permalink structure for posts in a specific category
- How to Remove Slug From Database?
- How to make draft posts or posts in review accessible via full url / slug?
- Limiting the number of words or characters in the slug/permalink
- How to increase the character limit for post name of 200?
- Custom rewrite rules for feeds of custom queries (query_var query strings in URL)?
- Change website URL without breaking links or images? WP 3.3
- WordPress 3.4 Permalinks Redirection Problem
- How to Modify Existing Rewrite Rules?
- Using ‘Primary Category’ in URL
- custom permalink/shortlink with base62 encoded post ID
- How can I get the permalink of a post before it is published?
- Add a URL prefix to permalinks of News category and sub-categories of posts only
- Can two products with the same name but different category produce unique URLs?
- echo post-permalink without http and www
- Confusion about how a URL is being parsed
- Get closest page ID from URL
- How to reset canonical URLs / fix redirect loop
- How to show the homepage on a different url, like site.com/blog instead of site.com?
- Custom permalink for search and pagination
- wordpress api using rest_route for other pages
- Force wordpress to display page with same url structure as categories
- How can i have a custom post type with more slugs for each post?
- URL rewriting: removing the site’s basename for a specific category
- How to include sub directory in sitemap? [closed]
- Get the url of a page template without using the page slug and ID
- Host frontpage via example.com and everything else via example.com/blog
- WordPress can generate numeric permalinks, which then 404
- display dynamic content based on url slug on custom page
- How to generate a list of all urls
- Pre-populate Slug / Permalink with URL
- How to use all tags in post permalinks
- Unique one time use URL
- Edit permalink for certain pages
- cannot link a external url, present page url acting as parent url
- Remove parent page from url
- Getting back a permalink from custom url
- Two URLs of one post is available
- Bulk append URL (add word to slug)
- replacing post ID by custom post name in url
- Access posts while mod_rewrite is broken
- Remove international characters from slug – Almost done – Bit help
- replicate url permalink after migrating to wordpress
- Can I change the URL structure for a CPT only?
- How to remove slug from front page?
- How to redirect old permalinks from https://exmaple.com/category/post_id to https://exmaple.com/category/post_id.html
- Modify post slug before saving
- Make a post inaccessible without a unique ID in the URL
- assets aren’t loading on a page but loads on others? slug permalink conflict?
- Multiple Taxonomy Items for Separate URLs
- WordPress keeps removing query var from the URL
- URL gives 404 error of my subfolder site when i change permalink
- Change Project permalink to custom URL
- How to construct a dynamic rewrite rule for child pages that passes more than one query var
- Why does one of my pages not have the option to edit the link?
- Using a template file for a specific custom URL
- Nested permalink without dummy parent page
- Giving specific category posts its own permalink structure returns 404
- Extra url paths as variable
- Passing parameter through permalink structure
- Custom Taxonomy rewrite rule causes 404 error on page or single post depending on if it’s set to “True” or “False”
- Adding query string to multiple page urls in a WordPress function
- Post links broken after migration
- I have Akamai pointing to a WordPress installation with a different URL. Is there a way to make WordPress use this for link generation?
- Added a prefix in URL permalink structure but the old structure still working!
- rebuilding/ rewriting a url to make it SEO friendly
- add bar in paging in the URL
- WordPress Page URL
- Remove/hide a specify category-name from the url
- How to change URL of my pages?
- Difference and usage of uri (e.g. get_directory_uri) and absolute path (e.g. get_directory)
- Imported posts using wrong domain name
- Issues with WordPress permalinks
- How to display post permalinks instead of pages?
- Using a taxonomy value as part of a post URL
- Change permalink when page category selected in admin
- Why is there a # and other characters in URL for WordPress site?
- Update permalinks after domain change
- How to avoid duplicate Url for the home page
- Are custom page templates being used to get this permalink structure
- Include language variable in url
- Removing parent page in URL for one page
- How to get the perfect WordPress, WooCommerce, Custom Post Type pretty permalinks?
- WordPress keep redirecting me to random URLs
- Remove parent product category slug from product_cat url woocommerce
- Standard Htaccess directives disappear by themselves
- Change default URL (or permalinks) in the back-end
- how to ensure url uses post_name and not query post id?
- Duplicate Content Issue with WordPress Permalink Structure and Primary Categories
- Can’t Remove Unnecessary Slug
- WordPress homepage shows default theme after migration – logged-out users see different content