posts_clauses

The WordPress Core posts clauses hook.

Description

add_filter( 'posts_clauses', (string) $filter_query_attachment_filenames ); 

Parameters (1)

0. $filter_query_attachment_filenames (string) => '_filter_query_attachment_filenames'
The filter query attachment filenames.

Usage

To run the hook, copy the example below.
  1. $filter_query_attachment_filenames = apply_filters( 'posts_clauses', $filter_query_attachment_filenames ); 
  2.  
  3. if ( !empty( $filter_query_attachment_filenames ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the posts_clauses callback 
  2. function filter_posts_clauses( $filter_query_attachment_filenames ) { 
  3. // make filter magic happen here... 
  4. return $filter_query_attachment_filenames
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'posts_clauses', 'filter_posts_clauses', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'posts_clauses', 'filter_posts_clauses', 10, 1 ); 

Defined (5)

The filter is defined in the following location(s).

/wp-admin/includes/ajax-actions.php  
  1. add_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); 
/wp-admin/includes/post.php  
  1. add_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); 
/wp-includes/class-wp-query.php  
  1. $clauses = (array) apply_filters_ref_array( 'posts_clauses', array( compact( $pieces ), &$this ) ); 
/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php  
  1. add_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); 
/wp-includes/post.php  
  1. remove_filter( 'posts_clauses', __FUNCTION__ );