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
- Python rest api post article, update problem
- Use Tag input metabox style for Categories
- Get all media categories
- How to rewrite the post URL according to the category?
- How to limit number of attachments
- WordPress category check
- Show category name and new articles and display page numbers. What function to use
- How to get latest posts from each category in regular order
- Add child category to parent on post creation and save
- WordPress URL Rewrite for dynamic and customized URL
- Custom taxonomy/category order
- wp_list_categories in in nav_menu
- Add multiple classes. Different style for each category tag
- Different menu navigation per category
- get_categories listing foreach with children
- category doesn’t showing up in admin
- How to customize categories panel?
- Custom post and category template pagination problem
- WP admin broken. Not saving catgories or adding categories to menu
- Removing subcategories from permalinks [duplicate]
- How to display all the categories a post is in
- Different banner for different section
- Why don’t posts show up in my categories on the frontend?
- Displaying Child Categories in carousel
- Get posts from 2 different categories
- Multiple category selection in post, shows less important category in breadcrumb
- I want to display the all the posts that are inside a certain subcategory
- Creating Category Specific menus
- Display list of categories filtered by date?
- Refine/Filter the Search Results by Category
- How to make the link to the category for a post go to corresponding page number in archive?
- Flat category URLs but retaining hierarchy?
- Creating a custom feed for categories that includes the first post’s featured image
- categories on attachment page
- A single category with a specific permalink structure differing from the standard set for the rest of the site
- Custom category URL rewriting
- Category archives with monthly pagination
- Putting a Category of posts under a Page
- Trying to add cat_ID to array for showing an image for specific Category
- List only child categories within posts
- How to build a simple nav system of custom post type categories and its posts?
- Get Number of total Parent Categories for Custom Taxonomy
- Older entries link within category page
- change recent posts based on category
- How to change how many list item show in category generated by file edit-tags.php
- Admin comments and user restrictions
- Two separate portfolio pages [closed]
- Drop posts from categories in MySql
- category url structure
- Style category link depending on category ID
- display posts from specific category on a page , in thematic child theme?
- Latest comments from each category?
- category pagination got broken suddenly
- Categories in admin interface: can they be collapsible?
- Category RSS feed doesn’t show category name
- Custom Walker for wp_list_categories
- custom post type category link redirects to index
- menu using category and tags
- Order by category titles
- Have parent category contain only one post?
- How to append category name to category ID in a form field
- How to remove specific categories from posts?
- wp e-commerce group product by category [closed]
- How do I make the category sidebar widget (stock) display the total # of posts including those in subcategories?
- Woo Framework: woo_cat_featured not populating
- Show category name, and last 5 post titles below category name?
- Category template to show different categories based on parent
- get_post_meta not working on category.php
- How can you change the permalink for pages?
- Page display certain Category Posts
- Customize category page for different custom taxonomies
- WordPress Post # of # filtered by category slug
- Does “show_option_all” in wp_list_categories do anything?