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
- WP Rest API – How to get featured image
- How to Change the Categories Order in the Admin Dashboard?
- How to remove categories filter from wordpress admin?
- Get page content by category or tag
- Using categories & “stickyness” together
- wordpress wp-json prefix issue
- Changing the category permalink structure
- Display WooCommerce product categories in a 4 columns custom menu [closed]
- Page with the same name of a category
- How to make category RSS feeds show full content
- Creating Pages that show specific blog categories [closed]
- If a post belongs to two categories how do I choose the main category?
- ping_status in JSON REST API
- Change post category based on latest posts views
- How to get the depth of a category’s subcategories
- in_category() works in single.php but not in page.php?
- functions.php conditional tag – only show in single.php?
- How do I create a way for users to assign categories to a post from the frontend of the website?
- Get categories from save_post hook
- Is it possible to restrict viewing of category PAGE to logged in users only?
- Display children of the category a post is assigned to
- Random post + categories + tags
- how to define category loop last class in the third
- Making the category & tag Description textarea bigger
- WordPress admin categories sort show is wrong
- Huge category CSV import does not work
- Needing a snippet for listing category specific tags
- Displaying Categories and Sub Categories
- Data storage for JS app using WP REST API
- Change thumbnail image depending product category
- How to list categories within tags?
- get_next_post set the category
- WordPress URL Rewrite for dynamic and customized URL
- Different menu navigation per category
- Page display certain Category Posts
- Conditional IF current cat is the smallest/last/end child cat THEN
- How to create a custom meta box field in category? [duplicate]
- How to create a subcategory to a PAGE on WP?
- Finding the category id’s on category intersection pages
- Display sibling categories on category page
- Getting the category title / description returns first matching post?
- I want to know how to output child categories related to parent categories
- why get_the_post_thumbnail( the_ID()) echos extra post id
- Allow user to select categories that will display in post loop
- How to fetch the highest category in the hierachry for a specific post?
- Woocommerce search form with category select
- How to not display subcategories in Recent Posts widget area?
- Getting the Most Recent Posts from Multiple Categories
- Display category title and three latest post inside the category
- How to store category and tags separatly on wordpress?
- Is the part “category” fixed to an URL to an archive or post?
- How can I use AJAX with check-box categories?
- wp_delete_term or wp_delete_category?
- List Categories By Specified First Character
- the category city made as a subdomain
- wp_get_post_categories not work currently on loop.php
- Inline If statement to echo CSS [closed]
- Get category base permalink
- WooCommerce showing active product categories on single product page
- how to exclude specific category types (uncategorized) from blog page?
- Show subcategory name selected in specific category woocoommerce
- Confused about category.php template – not working
- Best way to make a JSON API from WordPress?
- Style a category page the same way as the homepage?
- custom php file inside my custom folder of plugins directory is not caching
- Display Taxonomies in loop with template args
- How to assign image on specified category and not show the image on other categories
- How can I add a Categories page link to a menu? [closed]
- Display only the latest post
- get posts from 2 categories. (2 posts)
- How to add location as category?
- Converting Categories (with ACF fields) to custom taxonomies
- Category and tags are not working properly