The URL you’re using is not the URL that you’ve registered.
This code:
register_rest_route( 'news', '/news', array(
'methods' => 'GET',
'callback' => 'custom_api_get_news_callback'
));
Registers this URL:
http://localhost:8888/una/wp-json/news/news
But you’re sending requests to
http://localhost:8888/una/wp-json/news/all-posts
Nowhere in your code have you defined an all-posts
endpoint.
You either need to change /news
in register_rest_route()
to /all-posts
, or the /all-posts
in your URL to /news
. They need to be the same.
Related Posts:
- Full-Ajax Theme: parseJSON error while building a JSON object from a WordPress custom template
- AJAX search on post pages by custom post type
- Fetch All Posts (Including Those Using a Custom Post Type) With WordPress API
- importing third party json feed as custom post type [closed]
- Development of a WordPress Search Plugin – Best Practices
- Updating custom post meta with ajax
- Favouriting a Custom Post Type
- WordPress post sorting with AJAX
- Filtering custom posts with Ajax
- Prevent reload confirmation after AJAX save
- is_singular() not working if called via callback function of admin-ajax.php
- How to filter post data with AJAX on page?
- Debug whats going on inside a function called from AJAX
- Is there an easy way to AJAX-ify saving of post?
- Ajax filter with custom taxonomies
- Filter posts with ajax form and checkboxes
- How to use wp_mail in CPT page
- Recommended way to remove WP REST API returned data for custom post
- Filter custom post type archive page with custom taxonomies (categories) with AJAX
- Ajax form filter post by custom fields [closed]
- How to load custom post archives sub-pages with ajax?
- Display custom post data in sidebar w/ dropdown
- Getting the URL of the parent page
- Ajax Check Post Status
- Received nothing after executing AJAX post function
- Filtering WP_Query Dynamically on the Front-End
- Why get_posts() not returning only selected category posts from Custom Post Type?
- Storing posts from query and accessing later via AJAX call
- Loading custom content type from ajax results?
- How to add a custom-post-type post within another custom-post-type post edit screen using AJAX?
- AJAX load more for different custom post type loops
- Ajax Custom Post Filter is not filtering
- WP_Query inside foreach loop returning same value for all options when filtered using ajax
- JS innerhtml changing style when using AJAX
- Custom post type – use ajax to display sub pages
- Custom post type editor with dynamic selects, one drop down populating a second second drop down not working
- Load Custom_post_type categories post with ajax
- Dynamic Custom Fields
- Load Next Posts With AJAX not working with custom post type
- Pagination with custom query, custom search form, single and pages, ajax and no plugins
- Retrieve custom post types by custom taxonomies with WP_Query
- $post not working working in AJAX plugin with custom post type
- Load Next WordPress Posts With AJAX?
- Custom post type’s extra fields – how to handle?
- How to add/edit advanced custom fields on custom post type’s WordPress REST API?
- Using wp_localize_script to get data from cpt and pass it to maplace-js locations
- Getting 400 Bad Request on AJAX Call
- admin-ajax.php GET custom-post titles
- Post will not load via ajax
- Select2 AJAX and WP Query Returns ALL and does not filter
- ajax response not recieving
- WordPress notification if new post published
- filter by custom taxonomy using ajax
- passing values from functions.php to template
- Importing JSON feed giving Notice: Array to string conversion error
- How do I update_post_meta() or add_post_meta() with an AJAX call
- Multiple wp_editor instances in custom post type using Ajax
- Change Post Meta via AJAX from the posts list table
- Display custom-post type based on the Title matching the current selected value
- WordPress custom post type numeric pagination with ajax
- Ajax Post Filter | Split Taxonomy Into minPrice & maxPrice
- ForEach Loop iterates only once when inserting product variations
- WP_Insert_Post creating duplicate posts when logged in
- How to filter custom post type by multiple Taxonomies
- Not saving custom taxonomy while using ajax
- Search for custom field input of a custom post type in ajax live search
- Create/populate Custom Posts ACF fields from external JSON file
- Filtering posts based on three taxonomies
- WordPress next post by ajax call on button click
- Trying to list years (for a filter) but not all years display
- Use a template for a specific url slug without creating a page
- Publishing failed. The response is not a valid JSON response
- How to submit the date with ajax?
- How can I create a button that when clicked populates a div with a list of foods that are checked as a certain type of ACF?
- How to display “META” array in register_taxonomy
- Attend event form with ajax
- WordPress custom post type post item data – show/fetch only on click with Javascript dynamically?
- Populating Custom Fields from live JSON
- How to display custom post type pagination buttons when processing AJAX request
- My post loop needs to have 8 different post templates
- How do I use URL to fetch all posts of a particular custom post type?
- Show ajax form resuslts in page
- Dropwdown: Get taxonomy terms from posts that share preselected terms from 3 other taxonomies
- Ajax load more inside custom post type taxonomy
- Is there a best practice, or typical way to do AJAX updating for data on a custom admin screen or post.php?
- WordPress API only returning HTML
- Filtering custom post using Ajax and taxonomies, keep getting 0
- Convert Custom Post Data to Javascript Array for Autocomplete
- Fetch loop of custom post types with AJAX
- Collect custom post in a calendar
- Calling in Post Content via AJAX
- Submitting custom post from frontend,jQuery ajax, and custom validation – can’t find proper place to insert wp_insert_post()
- How to load more custom type posts through AJAX & LOAD MORE POSTS button
- Updating custom post meta with ajax
- Custom filtering on month value only of an entire date field
- Two different archive pages showing the same content
- update custom taxonomy with Ajax in edit.php file [duplicate]
- How to filter custom post data with AJAX?
- Internal Server Error when echoing an OBJECT from wp ajax action function in functions.php to JS file
- Load posts via AJAX without draft status