Delete WordPress Post From Frontend

by Lechu on December 4, 2008

If you are logged in as the admin, you can add a link to your post if you want to delete it directly from the blog post rather than going to the admin panel.

function wp_delete_post_link() {

    global $post;

    if ( $post->post_type == 'page' ) {

        if ( !current_user_can('level_10') )

            return;

        } 

    else {

        if ( !current_user_can('level_10') )

        return;

    }

    $message = "Are your sure to delete ".get_the_title($post->ID)." ?";

    $delLink = wp_nonce_url( get_bloginfo('url') . "/wp-admin/post.php?action=delete&post=" . $post->ID, 'delete-post_' . $post->ID);

    $link = "<a href='" . $delLink . "' />Delete This</a>";

    echo $link;

}
  1. Enable Turbo Mode for WordPress blog – Google Gears : Today I upgraded my blog to...
  2. Embedding Google Docs to your WordPress blog post : Many times you may be in...
  3. WordPress 2.5, automatic plugin upgrade demo : I upgraded this blog to wordpress...
  4. Try WordPress 2.7 beta 3 – Great Admin Interface : I just upgraded this WordPress Installation...
  5. 10 Top Plugins for WordPress Post : WordPress is one the most widely...
  • khan

    can u tell where is the post loop? i mean start and end of the post loop???