you should do something like this
//For update a page when use costum template
$post = get_the_ID();
$my_post = array(
'ID' => $post,
'comment_status' => 'open' // closed
);
// Update the post into the database
wp_update_post( $my_post );
Related Posts:
- Why do I get comment spam even with Akismet and Captcha?
- What tools are available for managing/writing to WordPress? [closed]
- How to change “You must be logged in to post a comment.”
- comment_post_ID 0 (cannot remove from dashboard)
- Using WordPress’ WYSIWYG for comments
- How to remove comment spam in WordPress
- How is comment spam received without a comments form?
- Does a reply to a wordpress comment notify the author of the comment?
- Link name in comments to Author page? Comment Author Meta in Comments?
- Showing comments only to same custom user role
- Linking comments from registered users to their profile pages
- Can I change what fields are displayed in the Comments form?
- How to enable reply on most-deeply-nested comments?
- Top Commenters: exclude admin
- Comments to Custom Post Type
- Wrong gravatar showing up?
- Get Comments: Direct link to specific comment + post title
- How to make comment text field un-required?
- How can I show comments in random order?
- Is there any way to override “break comments into pages” and “close comments for old posts” on certain posts, but not on others?
- migrate comments from old database to new database
- Toggle nested comments
- Comments Pagination as an unordered list
- How to get comments from multiple post type?
- Check the Comment in Reply or Normal State
- Is it possible to make wp insert last comment onto another page
- How to allow only Admins or Logged In Users to post links in comments?
- wp_insert_comment error. puzzled by date value
- Private replies for comments
- Show last n comments
- Threaded commenting: how to show threads by last active first?
- edit_comment capability for subscriber
- Hold comments for moderation only if user is not logged in
- How to add attributes to the comment form tag?
- How to add replyToUrl schema.org to WordPress comments?
- oEmbed does not work for comments
- Get comments from post and sort by commentmeta value
- Yoast makes comment_reply_link function output plain link to comment instead of reply link
- Problems with comments callback (Argument #1 is not an array?)
- Can WordPress comments have titles and taxonomy?
- Do I need to deal with WordPress SQL Injection
- Same email for all comments
- Comments system doesn’t like International domains
- Comments on homepage (index.php) are duplicated under posts
- Email notification to an email address other than admin for custom type post comments in wordpress
- List comments received by every posts of an specific author
- How do I reply to comments from admin panel on a tablet PC?
- Disable comments for a user? [closed]
- Polls with respective comments?
- Why does akismet prevent jetpack comments from appearing in my moderation queue? [closed]
- Filtering the Admin Comments List to Show Only Comments from the Current User?
- Comment Link from get_comments()?
- if null or int(0) value to 0
- Problem with WordPress Comment
- In wp_list_comments comment dates won’t work?
- Only show own comments in admin panel
- Where are comment ratings stored?
- Comments change the template name
- I can’t post comment via REST API
- how to SELECT for the current post id?
- WordPress scruity issue – Totally disable all comments by CSS — secure enough?
- Sending comment notifications to different recipients depending on taxonomy terms
- wp_new_comment requires author url and author email
- Custom comment link
- How to display the user’s comment status on the front end
- get_comments_number() vs. get_post_field( ‘comment_count’, ID )
- Where are comments coded when using custom theme?
- What is the point of get_comment_count() if you cannot limit by a comment type?
- Wrong IP address in comment section
- Comments turned off, but ‘Leave a reply’ link still there [duplicate]
- How to output number of comments with link to comments
- Highlight comments made by registered users of the site
- How do I make Twenty Ten display comments on the home page?
- It doesn’t matter if I have more than one comment. get_comments_number still equal to one?
- Simple spam check for valid domain in commenter’s email address
- Sort post comments from newest to oldest in pagination
- Get all comments associated with a specific page ID (comment_post_ID)
- Update post “A” on comment submition on post “B”
- How do I add custom field to Admin comment form and display
- I would like to count number of comments after 5 days ago
- Using Disqus with headless WordPress setup?
- Attaching author tag to the comment
- Comments counter only for Authors Posts
- How to show a “Comments Are Closed” message on posts where comments have been closed?
- Necessary to have a comments.php if there are no comments?
- Comments pagination on author page
- Comments page id wp_list_comments
- Disqus comments only show up on newest post
- How do you remove the ability for a user to make a comment or post on a page?
- wp_trash_post retrashes already trashed comments?
- Comment notification not working
- How to maintain changes to comment-template.php
- Return comments_link() instead of echoing it
- just show the field comment by clicking button
- If paginated comments don’t span to a second page, how do I hide the div wrapper?
- wp_list_comments() only returns when user is loged in
- Numbering only parent comments
- Is there a way to implement a commenting system such as that on medium or sitepoint in WP?
- comment_approved custom value
- TinyMCE in comment reply form showing toolbar but can’t edit reply