Created
September 16, 2024 09:32
-
-
Save kasparsd/fb71e2f3562653a7f3481c8b8b3f9e24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function preseto_rest_with_extra_post_stati( $query, $request ) { | |
if ( current_user_can( 'read' ) ) { | |
$query['post_status'] = [ 'publish', 'private' ]; | |
} | |
return $query; | |
} | |
add_filter( 'rest_post_search_query', 'preseto_rest_with_extra_post_stati', 10, 2 ); | |
add_filter( 'rest_post_query', 'preseto_rest_with_extra_post_stati', 10, 2 ); | |
add_filter( 'rest_page_query', 'preseto_rest_with_extra_post_stati', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment