Here you go, this creates a Delete Post link that only appears to the user if they are both logged in and the author of the post. When the link is clicked, they get a js confirmation asking them if they’re sure, which once clicked will delete the post. And it does work with Custom Post Types, tested it myself.
<?php if ($post->post_author == $current_user->ID) { ?><p><a onclick="return confirm('Are you SURE you want to delete this post?')" href="https://wordpress.stackexchange.com/questions/33046/<?php echo get_delete_post_link( $post->ID ) ?>">Delete post</a></p><?php } ?>
Related Posts:
- Allow member to have access to custom post type only. Permission to only edit their own posts
- With Rest V2 (WP4.7) how does one restrict certain RESTFUL verbs?
- Allow User to Edit Page Based on their Email
- Allow Author role to publish one post type and not another
- Registration and Custom Post Types – How to synchronize information?
- Roles for Custom Post Types
- Custom post type: check permissions and validate nonce
- read_post meta capability for anonymous users
- No Permission to add new Page, Post or CPT with Admin role
- Filtering results for post_type tells me I don’t have permission
- get_delete_post_link() only works for administrator, even if other user has exactly the same permissions
- Preventing role reading others posts
- Why “Mine” is the default view when adding ‘capability_type’ in register_post_type
- Front-end submitted post is published with admin ID as author
- How to create new permission for custom post types for doing specific tasks
- Remove Custom Capability
- Get the ID of the latest post
- Do_Shortcode not working for Embed
- How do you get the count of posts in an archive page?
- Custom post type permalink: only use %post_id% and remove %postname%
- Fetching private posts or custom post types via WP-API with basic authentication
- Remove admin menu for custom taxonomy attached to custom post type
- How do I list custom taxonomy terms without the links?
- Page not found taxonomy custom post type
- how to filter by last name for custom post
- Order Posts by Taxonomy and Meta Value
- Custom comment status possible?
- Get categories for a specific post – Custom post type
- Assign Page Template Within A Custom Post Type
- Group Custom post type in a page by its taxomony tag
- WPMU: Programmatically adding CPT posts to specific blog id
- Custom post types not imported properly
- query order by date on custom type: wrong order
- How do I echo the post type?
- Error after deleting Custom Post Type with a function (no trash used)
- Using posts and postmeta table to store custom Address Book Plugin data
- error in Advanced Search Form for Custom Post Types in WordPress array_key_exists() expects parameter 2to be array, string given
- Rewrite Custom Post Type URL slug
- Posts navigation in custom post type single.php not working
- Problem adding column to WC Subscription [closed]
- Custom Post Type | Fatal Error on register_post_type()
- Custom Post Types for Support Ticket plugin?
- How to sort custom post type posts in default order by multiple fields?
- WordPress theme options vs custom post types
- if custom posts type exists and there are posts load script
- Custom Post-to-Post with multiple parents?
- Query string parameters from custom fields, inconsistent results
- How can I update the permalink everywhere for a custom post type?
- create a template page for a post
- Adding Show Less/More link to Custom Post Meta
- Get custom taxonomies from multiple posts
- Post image in WordPress not appearing on home page
- WP_Query inside foreach loop returning same value for all options when filtered using ajax
- Displaying Posts from Custom Post Types
- Custom Post Types strange pagination problem
- Global $post shows null in some of my custom post types archive pages
- 404 in custom post type feed with mistake permalink
- Warning after create Custom post type with Roots theme
- Set featured image to archive.php
- Custom post type editor uses old tinyMCE
- Custom WP_Query doesn’t display all posts
- How can I use archive-{post_type}.php theme template?
- Custom Type add Transitions
- Get terms of a post but only if they’re also the child of a specific term
- WP API Response does not show my registered metadata
- How to add a lightbox to class mix?
- Problem with adding custom post type meta to header by plugin
- Creating alternate meta box context locations
- Get posts by category name
- Custom meta box in custom post type not working
- Custom-Post-Type – how can I get the only post by IDnumber?
- Post/Custom Post Type URL Access
- Problem while filtering by ‘category_name’
- Hide directly viewing content for custom post type
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- How to implement very unusual wordpress routing structure?
- multiple URLS for the same page
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- Category permalinks don’t work even after flushing
- meta query multiple values for the same key
- Change custom post taxonomy values from front-end
- Wp Query sort order from custom MetaBox
- Pages of my taxonomy terms are showing all posts
- Theme changing issues for Portfolio Custom Post Types
- How do you make a custom post type invisible for subscribers
- Custom Post Types UI paragraph style
- Is there a way to re-order the Custom Taxonomy drop-down on a Custom Post listing page?
- How to manage a custom post type archive as a page?
- retrieve custom post image through widget
- multiple custom post type category selection search
- Custom Search Template for Custom Post Types
- Displaying taxonomy icon outside archive page
- Limit number of posts under a post type?
- Why is my custom form saving with ‘autodraft’ as title and slug?
- Select Menu for Custom post Type does not save
- Tags and Taxonomy links not working for Custom Post Types
- Geolocate Custom Post Type on Save
- How to stream a linked file in WordPress
- Can I have a specific template for products even if they are standard posts and not CPT?
- Error 403 when posting comments to a custom post type from a different page