First you need to tell WordPress to show this custom field in the API response:
register_term_meta('category', '_category_color', ['show_in_rest' => true]);
Then you can filter the category term API endpoint like so:
add_filter( 'rest_prepare_category',function($response, $item, $request){
$color = get_term_meta( $item->term_id, '_category_color', true );
$response->data['color'] = $color ?: '';
return $response;
}, 10, 3);
Related Posts:
- I am getting error message on accessing menu-endpoint
- wp_get_post_terms is difference obj model than the one in rest api response
- How to create WordPress custom end point with multiple parameters?
- Seperate plugin and theme files
- Escape commas in REST API
- How much PHP and MySQL or MariaDB knowledge should I know to start writing WordPress themes and plug-ins and whatever else a beginner can edit?
- Consume legacy rest api dependent upon WP API plugin
- i need to resive data external api and show user
- How to modify WCMP Rest API response?
- how to add a button next to the wordpress view button?
- Classified ad website : which solutions to use? [closed]
- wp_remote_get() returns 403 while file_get_contents() does not
- Ability to make API calls out of WordPress as well as executing SQL?
- Access WordPress data from external PHP application.
- Limit post creation by role
- Making sure that a plugin’s scripts and stylesheets are included for dynamicaly loaded content
- Best place for short bio,image and button [closed]
- What are the specifics of WordPress development I need to know? [closed]
- Ajax with plugins returns 0
- Set plugin-values when creating post via REST-API
- WordPress shows error related to allow_url_fopen
- how to do login using woocommerce rest api From android
- How to create a code editor for my plugin .?
- How to show only next post pagination link using wp_link_pages()
- Finding the URL to be used to check if plugin is installed with a theme
- AFNetworking incorrectly interpreted WP_Error
- Js file is not adding using this code in functions.php
- wp_footer hook only working on homepage not in other pages
- How can I position ShareThis buttons manually when using the plug-in? [closed]
- Plugin can not display in my custom theme
- How to use get_template part in the plugin?
- Jquery NoConflict Problem
- Redirect to another page using contact form 7? [closed]
- Access WP_REST_Server from within plugin namespace
- Overriding Parent Theme… will cause plugins failure?
- WordPress premium theme development [duplicate]
- How do I combine a theme with a plugin
- How can I list all installed plugins/themes/versions from CLI/API?
- how to force tag page layout to use same as search layout?
- How can I show a different theme for admin users? WP 3.8+
- Great blogs site resources/tutorial for WordPress Developers? [closed]
- REST route from a plugin not working if WordPress is installed in a subdirectory
- How to show the number of website visitors in my theme
- Plugin retrieving results even after uninstallation
- How to write “alt” tag in image for wordpress code?
- Getting a Page via its post-name using WP REST API v2 and Postman
- WordPress REST API Plugin Development – Add Custom Endpoint
- multiple language website navigation menu suggestion
- How to multiply a post to test internal search results?
- Use different single.php file based on condition
- Customizing Titles on the Fly with Code
- Add SideBar/Widgets Just Below the Post
- Add filter on html tags,attributes on specific function in wordpress
- plugins not working in custom theme
- Release the plugin in the WordPress repository where redux is used
- How to execute plugin and theme updates from a web hook / endpoint?
- Shortcode Attributes to Return different $_POST
- How do I make reusable content blocks for header and footer when using WordPress headless with another front-end?
- What form should the $query media query array have for an Elementor page builder function? [closed]
- REST API can’t get the response manually
- How can I support plugins in a custom theme?
- How to use the CSS of the WordPress core in the development of my administration page?
- Redeclare function after plugin activation
- How to integrate together a website currently hosted WordPress.com and a custom web application currently hosted on Azure?
- Custom API plugin to execute 3rd party API to retrieve data
- is_rtl returns false while it should return true
- Include Minit plugin in theme [closed]
- Woocommerce singe product custom gallery output works just on the first slide
- What is the purpose of a companion plugin
- Remove Pagination for Product Category Pages WooCommerce
- Managing wordpress Themes & plugins for multisite
- How can I use my custom wordpress theme on two websites? [closed]
- Set up functions to be overridden without using function_exists() by short-circuiting them?
- Widget for specific category
- why need theme,if page builder is there in wordpress [closed]
- WordPress custom post type image in RSS
- Add user meta after a user has registered and logged In [closed]
- Visual Composer: Where do I find the source code of a custom element?
- How to customize this theme? [closed]
- Changing the Organize Series Listing Pages
- Inserting Plugins Into Blank Space of Externally Designed WordPress Theme
- WP Rest API and json_decode()
- WordPress /users/me endpoint request forbidden
- Best way to retrieve data in custom api extended from wp-api
- oAuth2 Authentication in WordPress using WP OAuth Server and WP API plugins
- WordPress API functions not working at AJAX functions.php call
- What’s the right way to implement functions in footer.php
- WP-API Custom Post Type json_no_route
- Don’t load the theme for a page FROM a plugin EDITED
- Extending a theme: build new features as plugin or core modules?
- Hardcode a form in Contact Form 7 [closed]
- Remember the Meta Value With Radio Buttons
- how to design change in woocommerce cart page and all other page also by theme? [closed]
- display unique post per category
- How do you create a re-useable HTML fragment in wordpress
- WordPress plugin with its own “site”/theme
- Override methods in Yoast SEO breadcrumb class
- Theme Functions run a function upon activation or preview
- Polldaddy doesn’t show up on own theme
- How to add an admin alert for missing plugins