Most likely it’s simply because $_GET['first']
is not defined when you try with ?second=case&id=204
.
Instead, try this CODE (assuming first
& second
can’t appear at the same time):
if (isset($_GET['api'])) {
if (isset($_GET['first']) && $_GET['first'] == 'case' && isset($_GET['id'])) {
// $query is the WP_Query Object
$post = get_post($_GET['id']); // $post contains the post object
header("content-type: application/json");
echo json_encode($post);
}
else if (isset($_GET['second']) && $_GET['second'] == 'case' && isset($_GET['id'])) {
// $query is the WP_Query Object
$post = get_post($_GET['id']); // $post contains the post object
header("content-type: application/json");
echo json_encode($post);
}
die();
}
Related Posts:
- WP REST API only returning partial list of users
- Implementing the wp json-rest api
- How can I cache WordPress Rest API Response
- Why aren’t tags and categories added in post request to WP Rest API
- body_class REST field in WP-API
- Rest WP_Error always return null
- Best way to make a JSON API from WordPress?
- WordPress Rest API custom endpoint optional param
- How do I cache (core) API requests?
- Fetch All Posts (Including Those Using a Custom Post Type) With WordPress API
- Slow REST API calls on self-hosted WordPress [closed]
- WordPress JSON output
- Retrieving pages with multiple tags using REST API
- how to authenticate for the REST API from a plugin and from command line
- WordPress API – Get Drafts
- How do I use the WP REST API plugin and the OAuth Server plugin to allow for registration and login?
- How to stop WP API endpoint from caching?
- Sending POST Request from server
- How to get the attached gallery in the rest API?
- WP API : date_query parameter
- get WP-API by page id
- Custom route for WP-API gives “rest_no_route” value
- Get more than 10 posts in a specific category with the wordpress api
- “rest_no_route” – Debug error
- utf8 encoding in json rest api
- Developing Themes with React/Angular
- curl POST work with user meta but not the custom user meta
- Create post with REST API in php with file_get_contents
- WordPress REST API “rest_authentication_errors” doesn’t work external queries?
- Displaying Content with WP Rest API
- Increase the page size of the WordPress REST API
- Options to get my custom post type metadata via the WordPress API
- How to Increase WordPress JSON API Speed?
- Keep user’s privileges on accessing contents in JSON response
- node-wpapi: how to handle authentication?
- WordPress REST API always misses parameters – rest_missing_callback_param
- Adding rest api endpoints to an old theme
- Develop REST API using WordPress for Android app [closed]
- WordPress REST API not returning all posts
- Calling an API to do authentication / user login
- How do I query my WordPress posts on another HTML page using the WordPress Restful API?
- Submit comment via JSON from Android device
- How to edit feature image with XML RPC?
- Is there a way I can fetch the WordPress Developer Code References with an API?
- How to add an endpoint for my custom post type? /wp-json/wp/v2/posts is working but it didn’t in the custom post
- How to clone all WordPress Rest API end points
- WP REST API and Access-Control-Allow-Origin
- How to convert and use JSON data from a remote WordPress server?
- JSON API and notification about registration
- Jetpack JSON API configure button not showing [closed]
- how to use nimble-API and Display data?
- WordPress Theme/Plugin Information API Response to Text and Button
- how to create JSON array [] for REST response?
- exclude particular category in api
- How to receive JSON payload from a digital device
- rest_cannot_create_user
- WordPress API “code”:”rest_no_route” with Custom Route
- Implementing URL JSON API Data into Website
- WordPress output data to another website and pull data
- Intergrate JSON into wordpress
- Loop through WordPress API response errors
- Autotrader API Integration
- REST API get featured image source for custom post type
- How do I filter Child Posts by Parent Post ID for Custom Post types in WordPress REST API response?
- Periodically Query an external API on wordpress site
- Extending the API I created to return category names
- Daily automatic update of stock quotes via REST API and Cronjob. Or is there a more sophisticated way?
- I would like to retrive JSON value and display it in wordpress page or widget
- Posting data from Ionic app to WordPress
- Expand author, tags and categories in the WordPress JSON API
- How to display parent category with first level child in REST API
- WordPress REST API Endpoint (Authors and Categories latest posts)
- How to create REST Based JSON API(how to modify the code below)?
- REST API And Error Codes – No Message
- Querying Posts Using JSON API
- How to login via wordpress api and get user details?
- How many users/load can the rest API handle?
- How get JSON from external API on every page load if not existing in transient?
- Send PUT remote request with BuddyPress checkbox
- AJAX request from Chrome Extension to WordPress Website
- How to Securely and remotely Create new user in wordpress using Rest API
- How get Themes list via REST api?
- WordPress JSON API returns normal site page in html. How do I get it to give me JSON?
- WordPress JSON API Extend to Create Users [closed]
- For using google api is it necessary to install the google client libraries for using Oauth 2 in wordpress installation?
- WordPress JSON data to and from database to be shown on rest point
- “No Access-Control-Allow-Origin header is present” even though it is in the entry file
- Enabling CORS with WordPress
- hybridauth (google OAuth integration) and WP problems
- Escape commas in REST API
- Call external API
- Populating Custom Fields from live JSON
- Passing data outside of WordPress possible?
- Post to WordPress API using cURL and login cookies
- Display Post Featured Image along with Categories via WP Rest API
- wp rest api (v2) filter not working (404 error – rest_no_route)
- WordPress PHP error getting posts from another wordpress blog
- Loading posts outside wordpress
- Login and register by API
- Woocommerce API for calling products by Category ID