Skip to content

Instantly share code, notes, and snippets.

@cheh
Created October 20, 2015 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cheh/ec191fce0d397e10f77f to your computer and use it in GitHub Desktop.
Save cheh/ec191fce0d397e10f77f to your computer and use it in GitHub Desktop.
Cherry4: Adds a `comments` support feature for a team single post
// Adds a `comments` support feature for a team single post.
add_filter( 'cherry_team_post_type_args', 'cherry_child_add_comments_support' );
function cherry_child_add_comments_support( $args ) {
if ( ! empty( $args['supports'] ) ) {
$args['supports'][] = 'comments';
}
return $args;
}
/**
* Loads the comment template in single team post.
*
* @see do_action( 'cherry_post_after' ) - hook in plugins/cherry-XXXX/templates/single-XXXX.php file.
*/
add_action( 'cherry_post_after', 'cherry_child_load_comments_template', 25 );
function cherry_child_load_comments_template() {
$post_type = get_post_type();
if ( 'team' !== $post_type ) {
return;
}
if ( ! is_singular( $post_type ) ) {
return;
}
if ( comments_open() || get_comments_number() ) {
comments_template( '/templates/comments.php', true );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment