WP already does this out of the box thanks to the include_children parameter of tax_query which is true by default.
So you do not need to tell it the sub-terms, just do something like this:
/wp/v2/posts?categories=1
Related Posts:
- Query only title/field/featured media of posts [closed]
- How to check WordPress website username and password is correct
- WordPress REST API call generates nonce twice on every call
- How to: Rest endpoint returning empty object
- Custom endpoint that returns an xml
- Plugin Sidebar is not Saving Meta Attribute to Post/Page after “Update”
- WP rest api v2 posts filter by ‘search’ & ‘category_name’ not working
- WordPress Plugin Setting’s POST
- What method to use to call a REST API?
- WP REST API V2 – Add user data to response
- Slow WP_query due to nested wp_query. Need Suggestions
- How can I pass get_the_author_meta(‘user_email’) through the REST API?
- How to get results of subcategories also?(WP Rest Api v2)
- Amending REST API function without deactivate/activate plugin every time changes is made
- Create a new post using rest api and save featured image using an external image url
- Adding custom end points, No error line
- Serve text/html from wp-json API via WPEngine, headers not being set properly
- Get attachments from a post
- Secure REST with nonce works only when not logged
- How to do POST request with WP REST API v2 to custom table?
- pre_get_post alter current post id
- rest_no_route on custom API endpoint wordpress
- Custom Rest Endpoint: Post/Put/Patch not working
- Why in this archive page that call query_posts() function show only the last 10 posts?
- Can’t retrieve body params from PUT endpoint using formdata
- Do I need to create an endpoint?
- WordPress Rest API with rest_do_request, possible race condition?
- How to use apiFetch to get author information in Gutenberg properly?
- Mock a dependency of a WP_REST_Controller class
- update_callback is not working in register_rest_field
- REST Endpoint API 404
- how to get the top 10 popular blogs
- Allow REST API Endpoint to specific user and hide from public
- Custom Endpoint – Does it possible to use PUT method with WP API Rest?
- How to do admin ajax request in a plugin for rest api
- Attaching Image-file to userId
- Query String Filtering API
- Custom plugin & calling REST api of wordpress instance the plugins is running on
- GET request return value as error instead of success
- How to query a nested field in wordpress api using _fields param
- Get Custom taxonomy parent with wordpress REST API
- register_meta not showing custom post type metabox data in rest api
- why is apiFetch throwing Unhandled Promise Rejection: TypeError: Object is not a function
- Securing custom rest API endpoints with public access from PWA
- WP_Query not ordering correctly
- 403 error rest_’cookie_invalid_nonce’ on API Request
- Adding Amchart Interface to WordPress API
- WC REST API Error Handling
- Initializing rest endpoint issue
- Multisite and the JSON REST API: How to?
- React in plugins: REST endpoints vs. regular functions
- admin-ajax.php returns “No Script Kiddies!” sometimes
- WP Query Relations / Compare
- WP API users per page
- How to limit the number of posts a user can view based on status
- How can I add recent posts to menu like mashable
- Best place to keep files that are called by cron jobs?
- Is it safe to use PUT and DELETE requests
- Is it possible to make WordPress as a RESTful app?
- Get next page in get_posts
- oneOf two possible objects in WP REST API?
- How to update WordPress Plugins in your own maintance application?
- Extend Plugin that creates an endpoint for GET request to also accepts POST requests
- How can create a custom plugin to call my webapi after any registration or membership plugin functionality
- Rest Api WordPress
- External api call using wordpress
- How to get recent one post from each category on home page?
- Does WP REST API cache internally executed (rest_do_request) requests?
- Run different permission_callback depending on HTTP method of custom REST API endpoint
- REST API error in block editor for custom templates
- How to get locale within WP REST Request?
- Execute callback after REST API request completes + Response is sent
- How to boost WP custom post REST API GET queries by custom taxonomies
- How do I return XML to an API post request
- Saving data-URI to media library
- What is the importance of writing a < WP 3.x compatible plugin nowadays?
- Current class on admin menu using add_submenu_page()
- Metabox Not Showing on Custom Post Type But On Pages and Post
- Using Checkboxes on Plugin Options Page for Custom Plugin
- Generating User(s) with Settings API
- Processing shortcodes in groups (separated by line breaks)?
- Including a JS source with an admin page
- Should action callbacks start with a verb?
- How to use a hook to override an update_post_meta call in a plugin?
- How to programmatically add a custom template that appears in Site Editor from a plugin?
- How to make “upgrade safe” theme for a plugin?
- Remove an action by extending class and replacing it
- Settings API: Setting default option via ‘get_option’ fails
- Setting a JSON web token from a secondary api as a secure cookie on WordPress
- How do I validate extra pin field on my WordPress login form page?
- Plugin to create Posts and Forums then choose category and parent forum
- Adding Permalink to Slides with ‘Simple Nivo Slider’ plugin?
- Adding the image selector/uploader to an admin back page
- How do I show the HTML descrption in wordpress photo gallery for my individual gallery pages?
- cancel place order proccess
- How I can give access to my custom plugin for editor roles user?
- Testing Plugins for Multisite
- WP: adding Javascript to specific woo commerce pages
- How To Remove The Filter That Adds JetPack Related Content To Dom [closed]
- Fixing plugin for wpdb::prepare