If you want a parameter to be required for a post type’s REST API endpoint you can use the rest_{$this->post_type}_collection_params filter to filter the $args of the GET endpoint:
add_filter(
'rest_car_collection_params',
function( array $query_params ) {
$query_params['visible_to']['required'] = true;
return $query_params;
}
);
Related Posts:
- How do I Filter Custom Post Type by Custom Taxonomy in the newest WordPress RESTful API?
- Saving Taxonomy Terms
- Custom post types filtered by taxonomy using REST API v2
- Filter get_categories() for taxonomy term in WordPress
- Ajax filter with custom taxonomies
- Filter posts with ajax form and checkboxes
- Highlight nav menu terms
- Help with issues on “Adding a Taxonomy Filter to Admin List for a Custom Post Type?”
- Want to filter only parent post in admin area
- What is better: Custom Fields vs Custom Taxonomies with Terms for perfomance, scalability and better user experience
- How to add custom fields to admin UI and REST API response?
- Wp Rest API request posts from a custom taxonomy
- Custom Taxonomy breaking pages permalinks
- Filter custom post type archive page with custom taxonomies (categories) with AJAX
- Custom Taxonomy Invalid in REST API
- How to query custom post types posts filtered by multiple custom taxonomies through a form selection
- Genesis filterable portfolio isotope [closed]
- How can I see a list of my Custom Post Types of the last term I was in?
- Displaying custom taxonomy in the admin list of a custom post type
- Categories of custom taxonomy don’t show any posts
- WordPress sort search results by custom order
- How to filter wp_list_categories output with some custom post type meta query?
- How to Filter custom post type by taxonomy?
- Filter term taxonomy metabox in custom post type
- How can I made custom taxonomies relationship?
- filter custom post in rest api with custom function
- Sort and filter custom post type posts by custom taxonomy
- Filter posts by tax (dropdown) and meta value
- How to see posts in taxonomy endpoint
- Only show posts with a specific term of an associated taxonomy in a custom post type archive
- Custom Taxonomy Filter Issues
- WordPress REST API V2: “{CUSTOM_POST_TYPE} matches Term ID List and Term ID Taxonomy Query, but should match only one.”
- Custom endpoint filtering post by custom taxonomies
- Custom Permalink For Custom Post Type – Working Fine But Broken For Pagination
- Store a value in global scope after init hook is fired
- Filter in Custom post type to find the parent post
- Insert custom taxonomy into category query
- filter rest api post by a acf filed
- Creating adminable dynamic filtering on custom post type
- Dropdown switching subcategories portfolio
- Exclude Custom Post Type from shared Custom Taxonomy
- Make term slugs of custom taxonomy available in WP REST API for custom post type?
- Add Custom Taxonomy Terms as CSS Classes for CPT Posts in an Elementor Loop Item Template
- Can’t retrieve custom post type taxonomy term to custom post type editor
- How can I remove the “Add New” button in my custom post type?
- Taxonomy, Terms, and Template Files
- custom post type or taxonomy
- How do I filter the excerpt metabox description in admin?
- Changing the priority of a custom taxonomy’s metabox
- How to list all categories and tags in a page?
- Admin to user notices – best practices?
- Multiple post types in archives (filter?)
- Many to Many Taxonomies or rewrite rules?
- Query posts by custom post type and custom taxonomy
- How to display the rest of categories on Portfolio filterable
- How to query custom post type by term?
- Custom Permalink with Dynamic Taxonomy for Custom Post Type – Works, but breaks other permalinks
- How can I show recent posts from same taxonomy as the post currently being viewed?
- How to get the first term for the current taxonomy?
- Group custom posts by custom taxonomy names
- Display Posts in Custom Post Types Timber
- Wrong request query on cpt and tax
- Custom post type multiple loop by taxonomy term
- Cannot add category or custom taxonomy from admin. WordPress site is hosted in Windows 16 server via IIS. No XAMPP or WAMP
- Listing posts under primary and secondary taxonomies
- What’s the WP way to load remaining custom posts?
- Listing custom terms in custom post meta
- WordPress subpages to custom post types
- Display posts with tag for custom post type only
- Can’t use pagination with custom taxonomy
- Hide specific taxonomies from a taxonomy list using ‘get_object_taxonomies’
- Targeting categories in custom fields
- sortable columns for multiple custom post types not working
- I need to add a filter to prepend the term ‘National – ‘ to the post title if the post is tagged to multiple states
- CPT Taxonomy As Archive Page – Error 404
- Custom post type specific category box
- Making a form for user to add new custom post with custom taxonomies and custom fields
- custom post type or taxonomy, which approach is better?
- Basic CPT Question About Categories
- custom post type and a “sticky” position taxonomy
- Redirect Custom Post Type from Child Taxonomies
- Ajax load more inside custom post type taxonomy
- How can I get the last 5 element of this tax query?
- Create a custom wp_query from a specific custom post type with specific taxonomy
- Show posts for current taxonomy
- order taxonomy alphabetical
- WordPress get all post with like in terms [duplicate]
- Custom post type archive page not showing on archive-posttype.php
- Query Pulling the same post twice
- Cannot retrieve Custom Taxonomies (Disappeared)
- Custom Post type and Taxonomy in post URL error
- Loop multiple taxonomy in custom post
- Sort a custom post type loop by a custom taxomomy instead of chronologically
- How to Create Custom Post Type with Multiple Color Options?
- Add custom taxonomies as class names to an archive page of custom post types
- Get all active posts that are tied to a custom taxonomy for a custom post type
- Paginate yearly archives for a custom post type
- Custom taxonomy meta fields
- How to add categories to a custom post type using wp_insert_post($new_post);
- Modify permalink of CPT archive to support two taxonomies