WordPress.org

Make WordPress Core

Opened 7 years ago

Last modified 5 months ago

#21758 new enhancement

Do not require a file in comments_template()

Reported by: mattonomics Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4.1
Component: Comments Keywords: needs-patch
Focuses: Cc:
PR Number:

Description

comments_template() is a very useful and reliable way to set up comments for a page, but it has a major downfall: it forces a file to be included when, in reality, one does not need to be.

Numerous times it has been the case that I needed comments to be setup in the wp_query object, but did not want to output anything at that time. The hack I have used is simply to include an empty comments.php file. This method is less than desirable for obvious reasons.

So, I propose that we simply add a parameter I'm calling $require that will control whether or not a file is included at all.

Attachments (1)

comment-template.php.patch (1.8 KB) - added by mattonomics 7 years ago.

Download all attachments as: .zip

Change History (6)

#1 @nacin
7 years ago

Rather than a new parameter, I think this makes the most sense as a separate function.

comments_template() can remain for template inclusion purposes, but a new function should handle setup. It might make the most sense as a method on WP_Query, such as get_comments() to match get_posts().

Things like set_query_var() would need to become $query->set() to be agnostic for any WP_Query object.

#2 @scribu
7 years ago

Or, how about we move all the comment stuff out of WP_Query?

#3 @rachelbaker
4 years ago

  • Keywords needs-refresh added
  • Milestone changed from Awaiting Review to Future Release

Sounds reasonable. Moving to future release.

Last edited 4 years ago by rachelbaker (previous) (diff)

#4 @wonderboymusic
4 years ago

the stuff that decorates $wp_query is gross and confusing

#5 @rachelbaker
4 years ago

  • Keywords needs-patch added; has-patch needs-refresh removed
Note: See TracTickets for help on using tickets.