Skip to content

Instantly share code, notes, and snippets.

@kasparsd
Created September 16, 2024 09:32
Show Gist options
  • Save kasparsd/fb71e2f3562653a7f3481c8b8b3f9e24 to your computer and use it in GitHub Desktop.
Save kasparsd/fb71e2f3562653a7f3481c8b8b3f9e24 to your computer and use it in GitHub Desktop.
<?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