Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'rest_gallery_query', function( $args ) {
- $args['meta_query'] = array(
- array(
- 'key' => 'book_id',
- 'value' => esc_sql( $_GET['book_id'] ),
- )
- );
- return $args;
- } );
- add_filter( 'rest_gallery_query', function( $args ) {
- if ( trim($_GET['book_id']) ) { // check if book_id is passed and is not empty, but you can modify this condition
- $args['meta_query'] = array(
- array(
- 'key' => 'book_id',
- 'value' => trim( $_GET['book_id'] ), // <- you don't need to esc_sql this
- )
- );
- }
- return $args;
- } );
Add Comment
Please, Sign In to add comment