Guest User

Untitled

a guest
May 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. add_filter( 'rest_gallery_query', function( $args ) {
  2. $args['meta_query'] = array(
  3. array(
  4. 'key' => 'book_id',
  5. 'value' => esc_sql( $_GET['book_id'] ),
  6. )
  7. );
  8.  
  9. return $args;
  10. } );
  11.  
  12. add_filter( 'rest_gallery_query', function( $args ) {
  13. if ( trim($_GET['book_id']) ) { // check if book_id is passed and is not empty, but you can modify this condition
  14. $args['meta_query'] = array(
  15. array(
  16. 'key' => 'book_id',
  17. 'value' => trim( $_GET['book_id'] ), // <- you don't need to esc_sql this
  18. )
  19. );
  20. }
  21.  
  22. return $args;
  23. } );
Add Comment
Please, Sign In to add comment