Created
October 20, 2015 14:45
-
-
Save cheh/ec191fce0d397e10f77f to your computer and use it in GitHub Desktop.
Cherry4: Adds a `comments` support feature for a team single post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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