Title: comments_open FUNCTION
Last modified: August 20, 2016

---

# comments_open FUNCTION

 *  [nemoxp](https://wordpress.org/support/users/nemoxp/)
 * (@nemoxp)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/comments_open-function/)
 * Hello.
    I believe this function is missing something… Wouldn’t be good a check
   on $_post or $post_id ?
 *     ```
       function comments_open( $post_id = null ) {
         if($post_id ){
       	$_post = get_post($post_id);
            if($_post){
       	$open = ( 'open' == $_post->comment_status );
       	return apply_filters( 'comments_open', $open, $post_id );
            }
         }
       }
       ```
   
 * I say this because i get a strange error when calling comments_open() with no
   parameter:
 *     ```
       Notice: Trying to get property of non-object in /home/hutanuro/public_html/catalin/wp-includes/comment-template.php on line 776
       ```
   

The topic ‘comments_open FUNCTION’ is closed to new replies.

## Tags

 * [comments_open](https://wordpress.org/support/topic-tag/comments_open/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [nemoxp](https://wordpress.org/support/users/nemoxp/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/comments_open-function/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
