In general, we log on to the background to manage articles and comments. if we can manage articles on the foreground, especially delete spam messages on the foreground, is it very convenient. The implementation method is very simple. just add the following two pieces of code to the appropriate location of the topic template.
In general, we log on to the background to manage articles and comments. if we can manage articles on the foreground, especially delete spam messages on the foreground, is it very convenient. The implementation method is very simple. add the following two pieces of code to the appropriate position of the topic template.
Delete an article at the front end
Source code from: http://wp-snippets.com/delete-post-from-front-end/
After running the original code, it is found that clicking "Delete post" will only go to a warning page, and the log will not be deleted, slightly changed.
Modified:
$ Url = get_bloginfo ('URL ');
If (current_user_can ('edit _ post', $ post-> ID )){
Echo'
Echo wp_nonce_url ("$ url/wp-admin/post. php? Action = delete & post = $ id ", 'delete-post _ '. $ post-> ID );
Echo '"> Delete post ';
}
?>
Delete comments at the front end
Source code from: http://www.ninthday.net/2011/08/magement-comments-front.html
The original code needs to manually modify the blog URL address, and you need to confirm before you can delete the comment. after modification:
If (is_user_logged_in ()){
$ Url = get_bloginfo ('URL ');
Echo 'Comment _ ID. '"href ="'. wp_nonce_url ("$ url/wp-admin/comment. php? Action = deletecomment & p = ". $ comment-> comment_post_ID. '& c = '. $ comment-> comment_ID, 'delete-comment _'. $ comment-> comment_ID ). '""> delete ';
}
?>
The HotNews topic adds the above code to the functions. php template:
Place the following sentence properly.
I have only tried this code in the HotNews topic, and I have not tried the topic of the comment template using the standard comment function.
I feel that the code used to delete the first paragraph of the front-end article is not very useful, but the comment deletion function on the front-end is very practical. it is nice to see a spam delete one!