How to disable the wordpress article comment function

Source: Internet
Author: User
Tags comments php file

You can set the comment option in the background. However, if we disable the comment function, all logs cannot post comments, and we generally do not, unless our blog does not need comments. Comments can also be forbidden when a single log is published or edited. However, this is quite troublesome, especially for blogs with a large number of logs. It is time-consuming and not worth doing so.

1. If you close the comments of an article, you will have a "discussion" below when posting the article. Just remove "allow comments" from the check box.

2. If you disable comments for all articles, choose "Settings"> "discussion settings" and click "allow comments from new articles" in "default article settings".

Procedure

Go to the management background and click "settings"-"discussion" in the left-side menu. In the "default article settings" on the right side of the page, remove the check box before "allow others to post comments on new articles.

 

How to close comments of an article

Www.111cn.net

Go to the management background, click "all articles", move the mouse to the bottom of the article you want to edit, a menu will appear, click "quick edit" to remove the check box before "allow comments" on the right, then save the article and you will not be able to comment on it. (You can set both the document and page.)

Automatically disable comments within a fixed period of time

This prevents the user from constantly turning over the old log. Refer to the following function to run Wordpress3:
The code is as follows: Copy code
<? Php
Function close_comments ($ posts ){
If (! Is_single () {return $ posts ;}
If (time ()-strtotime ($ posts [0]-> post_date_gmt)> (30*24*60*60 )){
$ Posts [0]-> comment_status = 'closed ';
$ Posts [0]-> ping_status = 'closed ';
}
Return $ posts;
}
Add_filter ('The _ posts', 'close _ comments ');
?>
Put it in the topic functons. Php file. The number "30" in the code indicates that the comment function will be disabled when logs are published for more than 30 days, and readers cannot comment on them any more. The length can be set to 60 days or 120 days.

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.