WP_REST_Menus_Controller::get_term() WordPress Method
The WP_REST_Menus_Controller::get_term() method is used to get a specific menu term from a menu. This is useful for retrieving a menu term by its slug or id.
WP_REST_Menus_Controller::get_term( int $id ) #
Gets the term, if the ID is valid.
Parameters
- $id
(int)(Required)Supplied ID.
Return
(WP_Term|WP_Error) Term object if ID is valid, WP_Error otherwise.
Source
File: wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php
protected function get_term( $id ) { $term = parent::get_term( $id ); if ( is_wp_error( $term ) ) { return $term; } $nav_term = wp_get_nav_menu_object( $term ); $nav_term->auto_add = $this->get_menu_auto_add( $nav_term->term_id ); return $nav_term; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |