For my needs, I customized the wp rest posts callback:
function get_all_posts( $data, $post, $context ) {
return [
'id' => $data->data['id'],
'date' => $data->data['date'],
'date_gmt' => $data->data['date_gmt'],
'modified' => $data->data['modified'],
'title' => $data->data['title']['rendered'],
'content' => $data->data['content']['rendered'],
'excerpt' => $data->data['excerpt']['rendered'],
'category' => get_the_category_by_ID( $data->data['categories'][0] ),
'link' => $data->data['link'],
];
}
add_filter( 'rest_prepare_post', 'get_all_posts', 10, 3 );
Category endpoint returns directly the name of the post category.
Related Posts:
- WP REST API: filter by category 1 AND category 2
- Why is per_page not working with categories in WP API?
- How to list categories and subcategories in JSON format?
- Get term by slug in Gutenberg
- Get ID of current taxonomy in register_rest_field
- How to add custom script to the particular Product Category page
- Select posts by name and category per REST API
- How do I query posts by a sub value with the API?
- wp_dropdown_categories() scripts working erratically on sidebar
- JSON REST API WordPress only showing first 10 categories
- Add image to each podcast series (or category) in headless WordPress instance [closed]
- wp_dropdown_categories not showing option as selected
- WP REST API not retrieving all categories
- javascripts files not linking to my category slugs?
- how to use nimble-API and Display data?
- Intermittent Gutenberg 504 Gateway Timeout when calling REST route to retrieve categories
- Pagination for custom categories template
- WooCommerce REST API not returning the default products category
- exclude particular category in api
- ADD DYNAMIC attribute for category to accordion
- How to check a category checkbox using JavaScript
- I would like to retrive JSON value and display it in wordpress page or widget
- Loading posts outside wordpress
- Connecting a wordpress site to an AngularJS APP
- Javascript code for Category
- Taxonomy term RestApi data 10 rows limitions
- Can’t filter categories using isotope
- Can JavaScript connect with MySQL?
- Using setTimeout on promise chain
- Get all categories and posts in those categories
- How to display non-hierarchical taxonomy as terms with checkboxes?
- Combine two taxonomies in a hierarchical tree
- Test if post has a category
- Make parent categories not selectable
- I want to order categories based upon the latest post time
- Headless WordPress: How to authenticate front end requests?
- How to find all posts without category and assign the “Uncategorized”?
- How to Override default update_count_callback for category
- WordPress previous_post_link exclude posts with multiple categories
- Android authentication
- Is it possible to put tags and category information in the post as text?
- Let visitors post comments on category page
- category_description() shows raw html after version 3.x?
- Is it possible to post with Word 2007 via XML-RPC and limit categories by user?
- how to get the categories for a single post in a hierarchical way
- Make parent category not selectable when it has child categories
- WP REST API format response
- Can I use get_adjacent_post for specific categories?
- How to Filter categories in the permalink structure
- Accessing WordPress MySQL Database via Data Connection in Visual Studio 2010 using C#
- Is there a cleaner way to get post count for a category in category.php?
- products nested by subcategories in a current category archive
- get_the_category() always returns empty array
- Post count for category and tag
- Get current_parent_category in a loop or Cat ancestor- big problem
- Is having thousands of unique categories a concern?
- How to prevent parent being choosen in wp_dropdown_categories
- How to build a simple nav system of custom post type categories and its posts?
- Style category link depending on category ID
- Categorie parents and childs displayed
- How to change amount of categories listed on dashboard?
- Display random categories
- Exclude a category name using cat name
- Link To Child Category For A Post
- Post by category+author not working!
- Custom template for sub-sub-categories
- How to remove the tilte “category:category name”?
- why category__and and category__in wont work togather?
- Advanced permalinks structure
- Subcategory Page URL to Display Only Posts from that Subcategory?
- Setting the Primary Category for a Post Based on Context
- Allow Custom Role to edit a custom post type category
- Custom Taxonomy Isotope Grid – Filter Buttons Not Working
- Shop Category Pages missing s
- Access checks with custom REST endpoints and backbone
- How to prevent tag “iframe” from being deleted from the heading description of rubric?
- Some subcategories not working on custom portfolio sort
- How can I make a category function as a page?
- Link For Portfolio Categories
- Create duplicate category page with content variations
- Renaming default category taxonomy?
- Category names dependent on each other?
- Category Template for Custom Post Type
- Loop Through Categories in Custom Field
- Backend – Categories and Menus conflicts
- Loop through posts of CatA and store value of CatB in separate array
- Highlight posts that belong to current sub category
- How to add an empty entry to masonry?
- Problem with single posts not showing correct category sidebar
- Multiple Categories under one URL, where ‘Front Page’ is used already
- finding out the top 5 source ( source is a custom taxonomy ), in a given category
- How to display many photo albums related to category
- Modify functions.php to add a term ‘uses-theme’ set to theme name on post save
- WordPress category gives 404 after moving to a different domain
- Create custom Perma link
- How to load/include category templates based on conditionals?
- Why does WordPress append a bullet to my category tag?
- how to implement next/prev within category archive?
- Add product category to post_class
- Replace category titles inside RSS feed