Make WordPress Core

Tagged: comments Toggle Comment Threads | Keyboard Shortcuts

  • Mel Choyce 8:35 pm on July 6, 2015 Permalink |
    Tags: , , comments,   

    Comments are now turned off on pages by default 

    In [33041] and [33054] for #31168, we’ve turned comments off on new pages by default.

    I know many of you have done the “make a bunch of pages, fill them out, realize comments are turned on, go back into the admin, turn off comments” dance. Now when you make a page, you won’t have to manually turn off comments β€” it’ll match the expected behavior of being off by default.

    In addition to pages, this functionality has been extended to all custom post types. Post registrations that don’t explicitly add support for comments will now default to comments being off on new posts of that type (before, they defaulted to on). Up until now, post type support for comments has only affected admin UI; a developer could omit comment support on registration but still allow comments to be posted. This is a change in behavior, and we will be closely monitoring its effects during beta. Moving to explicit support will allow core behavior to be more predictable and robust in the future, but we will always consider real-world usage.

    In trunk, you’ll notice two new things:Β the get_default_comment_status() function, which accepts the post type and comment type as arguments (both optional), and within it a get_default_comment_status filter, which receives the status, post type, and comment type as arguments. If you’ve been directly checking options such as with get_option( 'default_comment_status' ), you will likely want to replace those calls with get_default_comment_status(). We recommend explicit registration of post type support for comments, but as an example of using the filter, you can restore current behavior using the following:

     * Filter whether comments are open for a given post type.
     * @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 string (Maybe) filtered default status for the given post type.
    function wpdocs_open_comments_for_myposttype( $status, $post_type, $comment_type ) {
        if ( 'myposttype' !== $post_type ) {
            return $status;
        // You could be more specific here for different comment types if desired
        return 'open';
    add_filter( 'get_default_comment_status', 'wpdocs_open_comments_for_myposttype', 10, 3 );
    • Ihor Vorotnov 8:39 pm on July 6, 2015 Permalink | Log in to Reply

      Gods of Codes, thank you! Less junk in my mu-plugins now. And special thanks for CPTs – really good news these are :)

    • Frankie Jarrett 8:40 pm on July 6, 2015 Permalink | Log in to Reply

      Fantastic! Thanks to everyone involved in making this happen.

    • Dave Navarro, Jr. 8:41 pm on July 6, 2015 Permalink | Log in to Reply

      Awesome! Now how about making SUNDAY the default first day of the week on install?

    • Shapeshifter 3 8:43 pm on July 6, 2015 Permalink | Log in to Reply

      Good Decision for users of WordPress as a CMS!!! Thank You!

    • Shawn Hooper 8:44 pm on July 6, 2015 Permalink | Log in to Reply

      So happy to see this getting implemented!

    • Tony Scott 8:46 pm on July 6, 2015 Permalink | Log in to Reply

      Great news!

    • Navneil Naicker 8:52 pm on July 6, 2015 Permalink | Log in to Reply

      Awesome, thank you guys.

    • Morten Rand-Hendriksen 8:55 pm on July 6, 2015 Permalink | Log in to Reply

      Small changes like these significant positive impact on the WordPress user experience. Great move.

    • webdevmattcrom 9:03 pm on July 6, 2015 Permalink | Log in to Reply

      And the world rejoiced! Thank you!

    • leemon 9:03 pm on July 6, 2015 Permalink | Log in to Reply

      At last!!!

    • nbrowe46 9:05 pm on July 6, 2015 Permalink | Log in to Reply

      Great stuff! This reduces the things I have to do on a fresh install :)

    • Marco Milesi 9:06 pm on July 6, 2015 Permalink | Log in to Reply

      In my experience i’ve used comments in ~1/10 website. I usually use WordPress as a CMS instead of a blogging platform. So i would prefer to have comments disabled for posts too…

      NVM, one step at a time. Thank You!

    • Grant Palin 9:13 pm on July 6, 2015 Permalink | Log in to Reply

      Excellent. This has been a nuisance before when creating custom post types. Explicit opt-in is the way to go for this sort of thing.

    • Sakin Shrestha 9:15 pm on July 6, 2015 Permalink | Log in to Reply

      Finally, it’s nice. Thanks :)

    • Ansel Taft 9:16 pm on July 6, 2015 Permalink | Log in to Reply

      I’m thrilled with this change! May I inquire about media attachments (aka images)? Are they comment-enabled by default? We’ve seen a rash of comment spam on a couple sites to media attachments and would be forced to name my third-born Mattilda if such a thing could come to be. Cheers!

      • Helen Hou-Sandi 9:29 pm on July 6, 2015 Permalink | Log in to Reply

        Attachments are explicitly registered with comment support, yes. I’m not personally opposed to turning them off, though there are definitely sites that use comments for attachments – worth discussing. It is at least relatively trivial to turn comments off for attachments now, via remove_post_type_support() or the aforementioned filter.

        • Morten Rand-Hendriksen 9:31 pm on July 6, 2015 Permalink | Log in to Reply

          I would definitely leave attachment comments on by default because unlike all other post types there is no clear way for the user to do this on their own. If a user decides to direct a visitor to the Attachment page, there is a good chance that same user is looking to enable the comments section on that page.

          • Ansel Taft 10:14 pm on July 6, 2015 Permalink | Log in to Reply

            Morten, we land on the other side of the fence. We have yet to build a site where we would want/need comments enabled on attachments by default. We use media attachments on posts and comments are enabled on those which is perfect for our needs.

            • Helen Hou-Sandi 12:01 am on July 7, 2015 Permalink

              We don’t expose this in any of the Backbone-driven parts, no. I’ve used attachment comments on some sites (photo commenting vs. post commenting, much like Facebook has), and hate the spam problem on others. The spam can come even if you don’t have a comment form, which is also frustrating. I’m not sure we can really turn it off by default, but again, at least it’s easier to turn them off now. Which I should go do for some sites right now. :)

  • Ryan Boren 11:04 pm on October 24, 2008 Permalink
    Tags: comments,   

    Trying to decide what to do with comment permalinks when paging is turned on.

  • Ryan Boren 6:14 pm on October 22, 2008 Permalink
    Tags: comments   

    Adding some options to comment paging. Sort order and page order.

    • Petter 7:06 pm on October 22, 2008 Permalink | Log in to Reply

      I beleive the paged comments will be my favorite new WP 2.7 feature. If you keep me waiting much longer I’ll go betatesting :-S

    • Suskun 9:07 am on October 23, 2008 Permalink | Log in to Reply

      in one of the nightly builts, there was an option in comments section called “quick edit” which was very usefull. in coming releases will it be back?

    • Fabien 2:46 pm on October 23, 2008 Permalink | Log in to Reply

      The Paged Comments plugin has some interesting options : of course the order of comments but also an option to choose if the last comment-page will contain the maximum number of comments allowed on a page or not (fill last page option).

      I don’t know if there will be any ajax stuff to browse between comment pages, but if not, repeating the same article content on each page could be bad for SEO (duplicate content). Maybe an option like on_first_comment_page() could solve the problem (with a much appropriate name of course, but you have the point).

      Thanks for your great work and sorry for my english (French) .

    • monika 10:44 pm on October 25, 2008 Permalink | Log in to Reply

      I’m writing much tuts-and they have most of the time >100 comments. So I tried paged comments. But I have to realize that user do not read *comment-page-4* πŸ˜‰

      so I have same questions most of the time,

      is there a way for a *comment search*?

      and yes – please give me the chance to seo optimize the paged comments, because too much internal dc is very bad for a website.

      thanks a lot


  • Andrew Ozz 12:33 am on October 11, 2008 Permalink
    Tags: comments   

    Some changes and improvements to threaded comments: allows replying without JavaScript (patch contributed by Viper007Bond) and removes script dependency on jQuery. If the script fails for some reason (missing base css blocks, IDs, etc.) the no-js replying will be used instead.

    Added 2 new template tags used to allow replying without js, comment_parent_field() comment_id_fields() outputs the hidden form fields holding the reference to the comment’s parent and the comment_post_ID, and comment_form_title() outputs a different title above the form when replying (optional).

    Changes: cancel_comment_reply_link() takes only one argument text = ‘ ‘, the rest is set from js. The DIV surrounding it shouldn’t be hidden (for supporting no-js mode) and is optional.

    • Ryan 1:28 am on October 11, 2008 Permalink | Log in to Reply

      Maybe bundle the comment ID in with the parent ID inside comment_parent_field() and rename comment_id_fields()? That way it takes care of both of the required hidden fields.

    • Andrew Ozz 1:44 am on October 11, 2008 Permalink | Log in to Reply

      Good idea. The comments.php templates will have to be adjusted there a bit anyways, better to have one template tag that will output all necessary fields.

    • Ryan 7:06 pm on October 14, 2008 Permalink | Log in to Reply


    • monika 2:19 pm on November 2, 2008 Permalink | Log in to Reply

      ok there is one template tag and where can I translate all this in an individual way? the main gettext file -but now I can’t translate via theme .mo / .pot :( or?

  • Ryan Boren 8:10 pm on October 7, 2008 Permalink
    Tags: comments   

    Dogfooding threaded comments on this blog.

  • Ryan Boren 6:44 pm on October 6, 2008 Permalink
    Tags: comments   

    sivel.net has a howto on using the new comments API to separate comments from pings

  • Ryan Boren 5:19 pm on October 1, 2008 Permalink
    Tags: comments,   

    Alex landed a comment type filter for edit-comments.php. You can view all types, just comments, just trackbacks, or just pingbacks.

  • Ryan Boren 7:48 pm on September 29, 2008 Permalink
    Tags: comments   

    Otto has a great post on updating themes to use threaded comments. If you try out the new comments API, let us know what would make your life easier.

  • Ryan Boren 8:56 pm on September 22, 2008 Permalink
    Tags: comments   

    The comment paging patch is now usable. Time for review and then hopefully commit.

  • Ryan Boren 6:04 am on September 18, 2008 Permalink
    Tags: comments,   

    Hailin got a start on adding paging to the walker. Need to take this and hook it up to wp_list_comments() to allow comment paging.

compose new post
next post/next comment
previous post/previous comment
show/hide comments
go to top
go to login
show/hide help
shift + esc
Skip to toolbar