[wp-trac] [WordPress Trac] #28399: Allow WP_Query to query by comment_count column of CPT/posts table

WordPress Trac noreply at wordpress.org
Thu May 29 15:05:45 UTC 2014


#28399: Allow WP_Query to query by comment_count column of CPT/posts table
-------------------------------------+------------------------------
 Reporter:  ramon fincken            |       Owner:
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Query                    |     Version:  trunk
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  ui
-------------------------------------+------------------------------
Description changed by SergeyBiryukov:

Old description:

> In the current WP_Query, it is possible to order results by comment_count
> ASC/DESC.
> But is it not possible to query the table based on this CPT/posts table
> column. Therefor it is impossible to (for example) query posts without
> any comment or posts having over 10 comments.
>
> I propose a diff to use WP_Query in the following way (building on the
> syntax from meta_query and tax_query)
>
> a) Easy call:
> $args['comment_count'] = n; n >= 0
>
> b) Extended call:
> $args['comments']['count'] = n; n >= 0
>
> Optional in this call:
> $args['comments']['compare'] = Compare; Compare: =, !=, >, >=, <, <=
>

> I will extend this ticket with a patch diff file (trunk) along with a
> testset (has-patch).

New description:

 In the current WP_Query, it is possible to order results by comment_count
 ASC/DESC.
 But is it not possible to query the table based on this CPT/posts table
 column. Therefor it is impossible to (for example) query posts without any
 comment or posts having over 10 comments.

 I propose a diff to use WP_Query in the following way (building on the
 syntax from meta_query and tax_query)

 a) Easy call:
 `$args['comment_count'] = n; n >= 0`

 b) Extended call:
 `$args['comments']['count'] = n; n >= 0`

 Optional in this call:
 `$args['comments']['compare'] = Compare; Compare: =, !=, >, >=, <, <=`


 I will extend this ticket with a patch diff file (trunk) along with a
 testset (has-patch).

--

--
Ticket URL: <https://core.trac.wordpress.org/ticket/28399#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list