I am using custom post_type and inside the loop I echo get_delete_post_link but there is nothing echoing.
<?php
$wpquery = new WP_Query('post_type=myposts');
if( $wpquery->have_posts() ) {
while ($wpquery->have_posts()) : $wpquery->the_post();
$id = get_the_ID();
//just a test to see can I get post IDs and I get them
echo $id; ?>
<a href="<?php echo get_delete_post_link($id); ?>">Delete</a>
<?php endwhile; }
wp_reset_query();?>
This is the output
<a href="">Delete</a>
Is the user logged in and is allowed to delete posts of this post type? There are three checks inside the
get_delete_post_link
function before anything starts happening:I’m wild-guessing it’s the third check that’s failing in your case. You can paste them into your code and replace
return;
with debugging code to see what’s going on:All I can see that might cause this is the check for delete permissions.
If your user doesn’t have delete permissions for the post the function returns nothing.
There could also be a filter on
get_delete_post_link
.