Disable Comments For Link And Quote Post Formats

[ad_1]

WordPress introduced Post Formats with version 3.1. A Post Format is a piece of meta information that can be used by a theme to customize its presentation of a post. By default WordPress comes with number of standard post formats but themes are not required to support every format on the list. Support for a particular post format can be enabled or disabled from theme itself. These post formats support all post features including post comments which in my opinion, is not necessary for some of the formats. For example links or quote.

Most bloggers use link post format to feature external articles without needing to write any content. Therefore in most cases it’s completely unnecessary to accept comments on such articles. You can always disable comment on an individual post from post setting but disabling comments on all posts in one shot is much easier. That’s why in this article I will show you how to disable comments for post formats.

To disable comments on post formats, simply paste this code in your theme’s functions.php file. In this particular example I am disabling comments on link and quote post formats but you can extend to other formats which you do not require to have comments.

// disable comments for link and quote post formats
function wcs_disable_comments_post_formats( $open ) {
    if ( 'link' == get_post_format() || 'quote' == get_post_format() ) {
        $open = false;
    }
    return $open;
}
add_filter( 'comments_open', 'wcs_disable_comments_post_formats', 10, 2 );
[ad_2]

Leave a Reply

Random Post Selection ::

Recent Posts

Unlock Unlimited Downloads