Just use get_delete_post_link( $post_ID )
– it’ll return the absolute URL with nonce and all!
Just to be clear, this will get the link to trash posts (if trash supported). If you want to skip trash & get the perma-delete link, pass a second argument of *.true
http://codex.wordpress.org/Function_Reference/get_delete_post_link
Update: Having checked the source, it seems the codex is a little out of date. The second argument is deprecated, so pass an empty string & the third arg as true
:
get_delete_post_link( $post_ID, '', true );
Related Posts:
- Nonce for Trashing Item
- How does nonce verification work?
- How to expire a nonce?
- Fatal error: Call to undefined function wp_create_nonce()
- Using nonce external of WP Admin
- Nonce best practices: hidden input vs. wp_localize_script?
- “The link you followed has expired” when previewing a post
- wp_verify_nonce keeps failing
- Handling nonce generation in AJAX registration process
- increase nonce lifespan
- wp_verify_nonce() via REST always returns false
- Nonce failing in IE
- my theme breaks WP export
- Why am I getting a 403 from check_admin_referer()?
- x-wp-nonce across domains
- wp_create_nonce doesn’t verify when using WP_List_Table
- Handling expired nonces
- What is really “wp_nonce_field” and how does it work? [duplicate]
- Cannot verify nonce
- wp_verify_nonce return false despite correct parameter passed
- WordPress JSON API nonces and Vue development server
- Verify a nonce in Form submission
- phpcs error in WordPress
- Stop WordPress nonces expiring
- Several nonces?
- Nonce keeps failing
- Public posts – preventing duplicate form submissions
- How to obtain “wp_rest” nonce for WP Statistics plugin manually?
- WordPress “nonce” message
- CSP nonces with Cloudflare Workers
- Why are nonces working in Firefox but not in Chrome?
- wp_verfy_nonce keeps giving false
- Nonce – reissue with ajax poll
- wp_nonce_url generating invalid links
- How to insert wp_nonce field within echoed string
- Nonce check causing issues when creating new post
- Weird nonce validation problem
- Logout button in menu without “wp” in links
- Nonces can be reused multiple times? Bug / Security issue?
- Using nonce in menu item
- Remove Trash / Delete option for Custom Post Type / Taxonomy
- Should nonce be sanitized?
- WordPress REST API call generates nonce twice on every call
- trash_post action with Custom Post Type
- WordPress failure when logging out
- Reduce nonce lifespan
- Ajax function returns -1
- How to hook in to bulk trash posts
- WordPress has a trash for users? (Wrong result for count_user, greater than expected)
- Restrict access to the Trash folder in Posts
- How to change redirect after moving a page to trash?
- wp_verify_nonce always returns false when logged in as admin
- Error after deleting Custom Post Type with a function (no trash used)
- how to get nonce using json api
- Dynamically create/remove terms in taxonomy when custom post type is published/trashed
- AJAX requests broken due to HTTPS for wp-admin
- Restore trashed posts with comments
- wp_nonce_url to users.php for deleting user not working
- Deleted pages showing up when querying for child pages
- Security checking in meta_box save is reluctant?
- How to check an ajax nonce in PHP
- wp_verify_nonce not working
- Deleting the attached “comment replies” when trashing a comment
- how to send Ajax request in wordpress backend
- Shortcode to delete post from front end
- WP Admin AJAX Security – using POST to include a relative URL
- wp_create_nonce() in REST API makes user->ID zero
- ajax nonce verification failing
- wp_create_nonce function doesn’t work inside a plugin?
- Nonce failing on form submission
- Found 2 elements with non-unique id (#_ajax_nonce) and (#_wpnonce)
- Why ajax doesn’t work on certain wordpress hooks?
- Custom login doesn’t work properly
- Is there value in using a wp_nonce for POST requests?
- How to cancel the trash action inside wp_trash_post
- Missing ‘Move to Trash’ option from bulk select box
- Form Security: nonce vs. jQuery
- Get rid of “trash can” for custom post type
- Nonce doesn’t validate in nopriv call
- Should I use wp_nonce_field on my contact form?
- How to restore all items from trash
- Why does check_ajax_referer give a 403 error on https websites?
- WordPress is creating nonce as a logged in user but verifying it incorrectly
- How to use nonce
- Where to use nonce
- Re-use Nonce in Repeating Event Signup Buttons
- How to add a WordPress Nonce for this form to avoid CSRF
- Reliable way to add nonce to HTTP Header in WordPress?
- wp_nonce vs jwt
- Using a nonce Content Security Policy header for style-src for inline style elements returns errors
- wp_verify_nonce not working on the mobile device
- How to not cache nonces with WP Rocket?
- whether a nonce is required for get type and get_query_var?
- Unable to update plugins or log out
- Does it make sense to check a nonce on user log in?
- Override plugin function to show invoices even if not logged in
- CSRF attack to create USER
- WordPress deletes custom posts instead of trash them
- Is it necessary to use a WordPress nonce when allowing users to download public data?
- Wp doesn’t save meta box data