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
- WP Rest API: details of latest post including featured media url in one request?
- How to make plugin required in a wp theme without using php conditional statements when calling an individual function from that plugin?
- run silex or slim with wordpress
- Automatically install wordpress plugin at theme activation
- When coding a WordPress theme, where does the theme (i.e. the presentation) end and the plugin (i.e. the functionality) begin?
- Update Multiple Post Meta for the Same Post In One call?
- How to hide fields from my user profiles
- WordPress wp-json API – Custom Post Type returns 403
- How to make my plugin theme-independent?
- How to load a new template page according to a particular URL?
- Store post in raw markdown format, no html?
- Add custom buttons with custom actions in Edit Post screen in WordPress?
- Code in theme functions.php faster than with a plugin?
- REST-API: extend media-endpoint
- Workflow and best practice for documentation [closed]
- Keep user’s privileges on accessing contents in JSON response
- How to use get_theme_mod in gutenberg editor wordpress?
- How to Display a Plugin function (content) on frontpage using index.php
- How to make a slideshow shortcode based on the WordPress gallery shortcode? [closed]
- All of my custom posttypes are 404’ing
- How to save generated JWT token to cookies on login?
- How to modify WCMP Rest API response?
- Classified ad website : which solutions to use? [closed]
- Limit post creation by role
- Finding the URL to be used to check if plugin is installed with a theme
- Js file is not adding using this code in functions.php
- Redirect to another page using contact form 7? [closed]
- multiple language website navigation menu suggestion
- 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 use the CSS of the WordPress core in the development of my administration page?
- What is the purpose of a companion plugin
- why need theme,if page builder is there in wordpress [closed]
- 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?
- Changing the Organize Series Listing Pages
- What’s the right way to implement functions in footer.php
- How do you create a re-useable HTML fragment in wordpress
- Identify current wordpress theme
- Update WordPress Theme System
- Strange Behavior on New Theme Points to Idiocy
- Code for unique user visit count on every page WordPress
- Change Dashboard URL from wp-admin to wp-admin/index.php
- need to find duplicated meta value in custom filed and view the posts that have the same value
- Widgets are not displaying in the admin panel
- submit two file input fields in the same form
- How to send SMS notification to customer after click on submit?
- Content-Security-Policy implementation with WordPress W3Total Cache plugin installed
- woocommerce: Customize email with item total count
- Child theme modifications not showing up
- Submitting form to PHP
- how to change a static testimonials into dynamic
- Rename a folder via HTML POST request
- My wordpress local urls is still displayed even moved to live
- One WooCommerce Store to multi distributor sites
- Custom REST API POST Endpoint Not Working, 404 Error
- add tags to wordpress post using REST API
- Showing different js file for different theme in wordpress customizer api
- Modifying server’s response to API endpoint
- Change Jobs for WordPress templates
- WordPress panel is not loading after plugin activated with error: HTTP ERROR 500
- How to wrap image tag into div for post only?
- custom REST endpoint not passing body of POST request to callback
- Add section (add_settings_section) to a custom page (add_submenu_page) not working
- How can I add a custom checkbox / radio button on the admin theme options to display a CSS or other?
- Is it possible to restrict content in wordpress?
- Display Powerpress media url
- Why the output of an image gallery plugin is not displayed into a page of my custom theme?
- Convert HTML5/CSS3 site to WordPress Theme (need a lot of plugins) or just use the API?
- Plugin’s required JS not being inserted in my theme
- How to copy data from user profile page (profile.php) to theme customizer
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- What is the Object for WP_Error Class?
- Breadcrumb is not generating the correct post page url
- Replace all media (images)
- WooCommerce custom query and paging: Not Found error
- Integrating WordPress Content into a jQuery Slider
- How can I convert a complete bootstrap template into a WordPress template? [closed]
- Custom GD Star Ratings Stars [closed]
- Email Masking in widget
- Filter custom post type returned from REST api
- My wp_update_nav_menu action is firing twice
- Ajax button “Load more” is not loading correct language version posts for logged out users
- WordPress REST API Visual Composer Shortcodes
- Update post meta Rest Api
- I want to include My theme file (testing.php) to inside my plugin folder (myplugin/mypugin.php)
- How to Enfroce Domain Licensing Limits? [closed]
- Override plugin constant using a theme
- WordPress REST API filter on blank custom ACF
- WooCommerce REST API aborts connection [closed]
- How to update a lot of posts on my WP site with additional content?