I used
// Delete Post Link
function wp_delete_post_link($link = 'Delete This', $before = '', $after = '', $title="Move this item to the Trash", $cssClass="") {
global $post;
if ( $post->post_type == 'page' ) {
if ( !current_user_can( 'edit_page' ) )
return;
} else {
if ( !current_user_can( 'edit_post' ) )
return;
}
$delLink = wp_nonce_url( site_url() . "/wp-admin/post.php?action=delete&post=" . $post->ID, 'trash-' . $post->post_type . '_' . $post->ID);
$link = '<a class="' . $cssClass . '" href="' . $delLink . '" onclick="javascript:if(!confirm(\'Are you sure you want to move this item to trash?\')) return false;" title="'.$title.'" />'.$link."</a>";
return $before . $link . $after;
}
to add a delete post link in my custom theme,
<?php echo wp_delete_post_link(); ?>
but for some reason it is not deleting all the attached info. Only the post is deleted. I checked the Media Library and the attachments were still there.
How can I implement to delete everything linked to the post?
Note that I am implementing this on the front end and not the admin side.
Ok additionally, i added action for delete_post and in that called wp_delete_attachment function to delete the attachments. But the delete link generated by above mentioned tutorial
is giving wp failure page due to invalid nonce calculated. But it works perfect if i change action to trash. I need delete to be working. Can anyone help?