Display Message on Posts With Closed Comments

In the WordPress Dashboard, you can go to Settings > Discussion > Other comment settings > Automatically close comments on articles older than …. days.

comment-settings

This will remove the comments form on single posts when comments are closed however the comments will continue to display.

You can also use the single post settings in any Edit Post screen to disable comments on a post by post basis:

turn-off-comments

This setting won’t remove the comments, only the comments form.

If you want to display a custom message in replace of the comments form only on posts where comments are disabled, here’s the code to do that.

You can use any of the following genesis hooks for comments:

do_action( 'genesis_before_comments' );
do_action( 'genesis_comments' );
do_action( 'genesis_after_comments' );

do_action( 'genesis_before_pings' );
do_action( 'genesis_pings' );
do_action( 'genesis_after_pings' );

do_action( 'genesis_before_comment_form' );
do_action( 'genesis_comment_form' );
do_action( 'genesis_after_comment_form' );

Related Code Snippets

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.