Add the foreground article deletion and comment function for the topic

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.