WordPress.org

Support

Support » How-To and Troubleshooting » How to add a Delete link to each blog post?

How to add a Delete link to each blog post?

  • On our blog pages, how to add a Delete link to the line “Edit | Permalink | Comments ร‚ยป” ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • You want your members to be able to delete post or everyone?

    I think he means just the admin being allowed to delete the post (similar to the edit link).

    I also want to figure out how to do this, any ideas?

    I want admin to delete. Yes, the person above me is right.

    This should do it I think:

    <?php

    get_currentuserinfo();
    $postauthordetails = get_userdata($post->post_author);

    if ($userdata->user_level >= $postauthordetails->user_level) {
    echo '<a href="' . get_bloginfo('wpurl') . '/wp-admin/post.php?action=delete&amp;post=' . $post->ID . "\" onclick=\"return confirm('You are about to delete this post [bs]'" . $post->post_title . "[bs]'[bs]n [bs]'OK[bs]' to delete, [bs]'Cancel[bs]' to stop.')\">Delete</a>";
    }

    ?>

    [edit] Replace [bs] with a backslash. This stupid forum software keeps stripping them if I add them in. ๐Ÿ˜ [/edit]

    Use it within The Loop and it should only show up on posts made by someone of the same or lesser userlevel than the level of the current user.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to add a Delete link to each blog post?’ is closed to new replies.
Skip to toolbar