Opened 14 years ago
Last modified 7 years ago
#21758 new enhancement
Do not require a file in comments_template()
| Reported by: | mattonomics | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Comments | Version: | 3.4.1 |
| Severity: | normal | Keywords: | needs-patch |
| Cc: | Focuses: |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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.