Title: get_default_comment_status
Published: August 18, 2015
Last modified: February 24, 2026

---

# get_default_comment_status( string $post_type, string $comment_type ): string

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/get_default_comment_status/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_default_comment_status/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_default_comment_status/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_default_comment_status/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_default_comment_status/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_default_comment_status/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/get_default_comment_status/?output_format=md#wp--skip-link--target)

Gets the default comment status for a post type.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_default_comment_status/?output_format=md#parameters)󠁿

 `$post_type`stringoptional

Post type. Default `'post'`.

`$comment_type`stringoptional

Comment type. Default `'comment'`.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_default_comment_status/?output_format=md#return)󠁿

 string Either `'open'` or `'closed'`.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_default_comment_status/?output_format=md#source)󠁿

    ```php
    function get_default_comment_status( $post_type = 'post', $comment_type = 'comment' ) {
    	switch ( $comment_type ) {
    		case 'pingback':
    		case 'trackback':
    			$supports = 'trackbacks';
    			$option   = 'ping';
    			break;
    		default:
    			$supports = 'comments';
    			$option   = 'comment';
    			break;
    	}

    	// Set the status.
    	if ( 'page' === $post_type ) {
    		$status = 'closed';
    	} elseif ( post_type_supports( $post_type, $supports ) ) {
    		$status = get_option( "default_{$option}_status" );
    	} else {
    		$status = 'closed';
    	}

    	/**
    	 * Filters the default comment status for the given post type.
    	 *
    	 * @since 4.3.0
    	 *
    	 * @param string $status       Default status for the given post type,
    	 *                             either 'open' or 'closed'.
    	 * @param string $post_type    Post type. Default is `post`.
    	 * @param string $comment_type Type of comment. Default is `comment`.
    	 */
    	return apply_filters( 'get_default_comment_status', $status, $post_type, $comment_type );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/comment.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/comment.php#L303)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/comment.php#L303-L336)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_default_comment_status/?output_format=md#hooks)󠁿

 [apply_filters( ‘get_default_comment_status’, string $status, string $post_type, string $comment_type )](https://developer.wordpress.org/reference/hooks/get_default_comment_status/)

Filters the default comment status for the given post type.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_default_comment_status/?output_format=md#related)󠁿

| Uses | Description | 
| [post_type_supports()](https://developer.wordpress.org/reference/functions/post_type_supports/)`wp-includes/post.php` |

Checks a post type’s support for a given feature.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/get_default_comment_status/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_default_comment_status/?output_format=md#)

| Used by | Description | 
| [get_default_post_to_edit()](https://developer.wordpress.org/reference/functions/get_default_post_to_edit/)`wp-admin/includes/post.php` |

Returns default post information to use when populating the “Write Post” form.

  | 
| [wp_insert_post()](https://developer.wordpress.org/reference/functions/wp_insert_post/)`wp-includes/post.php` |

Inserts or update a post.

  | 
| [wp_xmlrpc_server::mw_editPost()](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/mw_editpost/)`wp-includes/class-wp-xmlrpc-server.php` |

Edits a post.

  | 
| [wp_xmlrpc_server::mw_newPost()](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/mw_newpost/)`wp-includes/class-wp-xmlrpc-server.php` |

Creates a new post.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_default_comment_status/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.3.0](https://developer.wordpress.org/reference/since/4.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_default_comment_status%2F)
before being able to contribute a note or feedback.