Removing the conditionals for the set()
calls will solve the problem. I suspect that the REST request is populating those parameters, and as such the set()
calls do not occur.
Untested:
add_action( 'pre_get_posts', 'test_pre_get_post_filter' );
function test_pre_get_post_filter( $query ) {
if ( is_admin() ) {
return;
}
$query->set( 'post_status', array( 'publish' ) );
$query->set( 'posts_per_page', 7 );
$query->set( 'orderby', 'title' );
$query->set( 'order', 'asc' );
}
Related Posts:
- How to: Make JWT-authenticated requests to the WordPress API
- How would I add custom tables/endpoints to the WP REST API?
- WordPress REST API validation
- Are there server performance benefits to fetching only specific fields when querying the REST API?
- How to define a query parameter with REST API?
- How do I correctly setup an AJAX nonce for WordPress REST API?
- WordPress Rest API: How do we validate with our custom API key?
- Adding WordPress API Endpoint With Multiple Parameters
- Using the REST API (v2) javascript client on a private namespaced route
- authentication issue with rest api – rest_cannot_create
- Match REST API post output from custom endpoint
- How to change user avatar using REST API?
- rest api authentication
- Does accessing WordPress via REST API affect the site stats and analytics?
- Build on same WordPress or different install?
- Testing custom API endpoint with class dependency
- How to properly add custom entities in Gutenberg
- REST API custom endpoint without authentication for POST method?
- CORS & Remote access to WP via RestAPI
- Create Session with JWT
- Not all featured image sizes available in Rest API
- WP API ignores filter parameter
- 403 Forbidden with gutenberg
- Detect if REST API is running
- Using pre_get_posts, how to target the REST API, only?
- Save/update post_meta with Gutenberg from the panel
- Set featured image using URL with wp rest api
- How to block all REST API endpoint except which I wrote custom?
- Authentication with internal WP_REST_Request and rest_do_request()
- How to use REST API to send user metadata?
- Can the new REST API now make WP into it’s own push notification server?
- Cannot DIsplay a Snackbar Notice on Button Click – Notice is undefined
- Use the backbone.js client to save custom post type meta
- Override WordPress POST REST API
- Custom Post Type and Custom REST API Endpoint result in Gutenberg editor not working
- rest_sanitize_value_from_schema doesn’t sanitize string
- Erratic OAuth 1.0 Signature Mismatch Errors
- Creating a custom endpoint for rest, I see the endpoint exists in the wp-json, but the request is returning 404
- WordPress + Vue — Single page app giving me 404s when I use query params
- No ‘Access-Control-Allow-Origin’ when call rest API
- WordPress Rest API custom endpoint for RSS feed
- How to add a custom REST field to limit data when fetching?
- Get subscribers via REST API and send post notification
- 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
- How to Get Featured Image from REST API?
- Allow “wp-admin” edit access through headless WP web application
- REST API authentication for a plugin
- rest api request including meta_query filter
- Rest API basic auth not working
- Error invalid parameters with REST API
- How to get featured image in WP rest api
- Filter DELETE REST API calls
- Rest API: wp_verify_nonce() fails despite receiving correct nonce value
- Update user meta via REST API?
- How to call wp plugin REST functions without curl?
- Disable part of endpoints wordpress api
- Get a term object using getEntityRecords
- How to send the body in wp_remote_post as “raw”?
- Backbone with custom rest endpoints
- rest Api jwt authentication for get methodes
- REST API and filtering by meta value
- Custom Endpoints not working
- Is there a way I can fetch the WordPress Developer Code References with an API?
- Pull in ALL posts from the last two weeks using Rest API
- How to add an endpoint to WP
- How to set up the REST API to refer to media on a CDN
- 403 error when publishing a post in wordpress. Error => Publishing failed. The response is not a valid JSON response
- Cannot use WordPress Application Passwords: “code”: “rest_no_route” “status”:404 for /wp-json/wp/v2/users/me/application-passwords
- IIS Authorization Rules breaks WP REST-API and results in fail in Site Health
- How to delete all instances of the image using REST API
- REST API connection on another site with post information and permalink
- Performance of WordPress Rest API vs WordPress Feeds
- trigger WordPress rest any API call
- WordPress REST API in Integromat: How to overcome “Sorry, you are not allowed to list users / edit this…”
- WP REST API returns empty posts despite entries in wp_posts
- The REST API encountered an error in wordpress?
- Do something when publish a post in Gutenberg with hook rest_after_insert_post
- Uploading picture via REST API
- How to modify the HTML output of Gutenberg block? (Youtube)
- rest api add post meta
- Can I use REST API if the site is protected with .htpasswd
- phpmailer_init ignored on REST calls
- Autotrader API Integration
- order by meta start_dato value (ACF)
- Display Post Featured Image along with Categories via WP Rest API
- Register rest field authentication with REST API
- Return all custom taxonomy terms for post in REST API v2? Currently limited to 10 terms
- Handling _embed for custom REST API endpoints
- Restructure Objects coming from Rest-Api
- Rest api request throttling
- Securing REST API wp-json/wp/v2/users endpoint
- Getting current core version from an WordPress installation
- How to block external access to register_rest_route callback?
- Filter output of posts (Rest API)
- WordPress REST API won’t allow me to filter by author ID when called internally, works externally in Postman
- Rest API is running, but /wp-json/wp/v2/ shows only old dates
- WordPress Application Passwords not authorizing
- Rest Api Error ‘ Error: {‘code’: ‘rest_no_route’, ‘message’: ‘No route was found matching the URL and request method.’, ‘data’: {‘status’: 404}}@ [closed]
- How can I get the number of items stored under a cache group