• Posted: 2011-04-15
  • Author: Andreas Hermosillla
  • Tags:

Delete Post From Front-End

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
<?php
$url = get_bloginfo('url');
  if (current_user_can('edit_post', $post->ID)){
    echo '<a class="delete-post" href="';
    echo wp_nonce_url("$url/wp-admin/post.php?action=trash&post=$id", 'delete-post_' . $post->ID);
    echo '">Delete post</a>';
  }
?>

Instructions:

Put this snippet in index.php, page.php or in single.php within the loop to display a delete link for anyone with the rights to edit posts.


Related links:
http://wordpress.org/support/topic/delete-post-on-front-end
Share this snippet

If you like this snippet, share it with friends!