We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello, It is not working for custom post types while the Wordpress API itself works for it naturally.
The text was updated successfully, but these errors were encountered:
Do you know? Is that the filter for custom post types? - https://github.com/WordPress/WordPress/blob/1f85e7484f154912d8869886ee3e5b68b06c0bc4/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php#L254 So it should be short to enhance the filter types of the plugin.
Sorry, something went wrong.
Alternatively, we get all post types and add the public post types to the filter list, like
// For post types. $post_types = get_post_types( [ 'public' => true ], 'objects' ); foreach ( $post_types as $post_type ) { $show_in_rest = ( isset( $post_type->show_in_rest ) && $post_type->show_in_rest ) ? true : false; if ( $show_in_rest ) { $post_type_name = $post_type->name; add_filter( 'rest_prepare_' . $post_type_name, [ $this, 'my_filter' ], 20, 3 ); } }
// For custom taxonomy. $tax_types = get_taxonomies( [ 'public' => true ], 'objects' ); foreach ( $tax_types as $tax_type) { $show_in_rest = ( isset( $tax_type->show_in_rest ) && $tax_type->show_in_rest ) ? true : false; if ( $show_in_rest ) { $tax_type_name = $tax_type->name; add_filter( 'rest_prepare_' . $tax_type_name, [ $this, 'my_filter' ], 20, 3); } }
No branches or pull requests
Hello,
It is not working for custom post types while the Wordpress API itself works for it naturally.
The text was updated successfully, but these errors were encountered: