This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
posts_distinct_request filter
Filters the DISTINCT clause of the query.
apply_filters_ref_array( 'posts_distinct_request', string $distinct, WP_Query $query )
Description
This is a filter hook that filters the DISTINCT clause of the query. It’s especially useful for caching plugins. It consists of two parameters: $distinct and $query.
Parameters
- $distinct: (string) The DISTINCT clause of the query.
- $query: (WP_Query) The WP_Query instance (passed by reference).
Live Examples
Basic Usage
To run the hook, copy the example below:
$distinct = apply_filters( 'weplugins_posts_distinct_request', $distinct, $query ); if ( !empty( $distinct ) ) { // everything has led up to this point... }
Adding a Hook Callback
The following example is for adding a hook callback:
// Define the weplugins_posts_distinct_request callback function weplugins_filter_posts_distinct_request( $distinct, $query ) { // Make filter magic happen here... return $distinct; }; // Add the filter add_filter( 'weplugins_posts_distinct_request', 'weplugins_filter_posts_distinct_request', 10, 1 );
Removing a Hook Callback
To remove a hook callback, use the example below:
// Remove the filter remove_filter( 'weplugins_posts_distinct_request', 'weplugins_filter_posts_distinct_request', 10, 1 );
Contact Us
Need customization? Contact Us
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.