[wp-trac] [WordPress Trac] #55287: Allow for DISTINCT in WP_Query method

WordPress Trac noreply at wordpress.org
Tue Mar 1 15:55:09 UTC 2022

#55287: Allow for DISTINCT in WP_Query method
 Reporter:  simbaclaws         |      Owner:  (none)
     Type:  feature request    |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  trunk
 Severity:  normal             |   Keywords:  needs-patch
  Focuses:                     |
 Dear wordpress developers,

 Currently I'm working with a plugin to create designs.
 This plugin has an element called a repeater element that basically makes
 use of the core WP_Query method in order to fetch custom post types or
 normal post types.

 However, since I'm using this page builder or theme builder, I am in no
 way capable of using DISTINCT within the filter
 Because this requires me to send the WP_Query instance, which is basically
 only used within the repeater element and can not be set to a variable in
 this particular case.

 This means I'll have to rebuild everything through code, instead of being
 able to use my page or theme builder.

 Now I get the idea of saying this is a bug with the page or theme builder
 But in fact, what I want to know is why are we using a filter to create a
 DISTINCT query inside of WP_Query? Isn't it possible to implement this
 inside of the WP_Query arguments instead? I basically want to say: fetch
 posts with unique titles. This seems much more logical as the SQL query is
 build from WP_Query...

 I've already looked through the entire codex, and couldn't find any
 possible parameter that could be used for this...

 My question to you is: Can this please be added to wordpress core?
 I find it highly frustrating that WP_Query doesn't have this sort of
 capabilities out of the box.

Ticket URL: <https://core.trac.wordpress.org/ticket/55287>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list