Questions tagged [rest-api]

Questions about the core RESTful HTTP API for accessing WP content and data.

Filter by
Sorted by
Tagged with
2
votes
1answer
37 views

WordPress REST get all items without a taxonomy assigned

i am a bit stuck right now. What i want to achieve is doing a request to the api that returns all posts that do not have a taxonomy assigned. I can do this request to get posts from a specific ...
2
votes
2answers
889 views

WordPress Rest API: How do we validate with our custom API key?

How we can verify "Cancel the header auth" the "endpoint" functions of WordPress with an API key that we produce. (Note: not a different endpoint, original endpoints) I have my own "Crypto" class/...
2
votes
1answer
76 views

How can I set status='publish' for all featured images?

Background: I've come accross this WP issue: https://core.trac.wordpress.org/ticket/41445 In short: when you make a request to a post over the REST API, if the featured image was originally uploaded ...
2
votes
2answers
391 views

Transition from (classical) serialized custom meta field to (gutenberg) rest enabled meta

I have a custom meta box for saving values from two input fields into a single post meta field. The data is saved serialized in the DB: get_post_meta( $post->ID, '_custom_key', true ) will ...
2
votes
1answer
1k views

How to update custom meta fields with rest api?

I get the custom meta field with rest api but not able to create or update. I'm not a programmer, I tried different solutions found on various sites but it does not work any . I used postman, the ...
2
votes
1answer
411 views

Rest API invalid nonce with Backbone Client

I'm using the built-in Backbone Client whenever I try to make a request it gives me this error: {"code":"rest_cookie_invalid_nonce","message":"Cookie nonce is invalid","data":{"status":403}} I read ...
2
votes
2answers
5k views

authentication issue with rest api - rest_cannot_create

I am using the rest api in Wordpress. For authentication I use the Basic authentication plugin (JSON Basic Authentication) I use this request (from both postman and nodejs): POST /wp-json/wp/v2/...
2
votes
1answer
1k views

rest_post_query on multiple post types?

how do you get the rest_post_query filter to work across multiple post types? I'd like to modify the orderby for all post types but at the moment i have to specify "post" in the filter name, which ...
2
votes
1answer
2k views

Query the REST API for a Tag by slug

Is it possible to query the API directly using a tag slug rather than a tag ID? Or do you have to query the main tags endpoint to find out its ID? For reference, you can fetch a tag this way: GET /...
2
votes
1answer
1k views

Wp Rest API request posts from a custom taxonomy

I'm trying to get posts from a custom taxonomy term in a custom post type but it is just displaying all the posts in the custom post type. I've tried using Filter in my endpoint url but I have a ...
2
votes
1answer
2k views

Increase the page size of the WordPress REST API

A client is using the WordPress REST JSON API with some WordPress data models. We need to hit the WordPress API from the frontend and retreive a few hundred custom posts. Wordpress has a hard limit ...
2
votes
2answers
967 views

Override json encoding in rest api

I'm trying to create a secure download plugin. I found the rest api the best option for this task, but i cant change headers like Content-Type:. In the register_rest_route callback these headers ...
2
votes
1answer
2k views

Rest API Custom Endpoint with space character

I'm trying to add an endpoint with the following: register_rest_route('namespace/v1','custom-search/(?P<search>[a-zA-Z\s]+)', array( 'methods' => 'GET', '...
2
votes
2answers
1k views

What method to use to call a REST API?

I am building a plugin for WordPress which will communicate with some remote REST API endpoints and display data in a list format in the public-facing view of WordPress. Which method I should go for ...
2
votes
1answer
66 views

Build on same WordPress or different install?

I need some opinions and suggestions to help me get out of this dilemma. Firstly I'm sorry if this kind of question isn't allowed in here. I'm not a real programmer but I've been doing WordPress for ...
2
votes
1answer
4k views

WP REST API: Order posts by meta value (acf)?

I'm requesting posts with the WP REST API and need to sort them according to an ACF field. It's value represents a date (numeric, jQuery date format yymmdd). I know how to do it with a normal WP_Query ...
2
votes
1answer
5k views

WP Rest API Querying Custom Posts by ACF fields

I have custom posts that represent real estate property and they have an ACF field of price. I'm trying to use the WP Rest API to query a certain price range, but to no avail. E.g. querying the ...
2
votes
1answer
3k views

WordPress API - Get Drafts

I want to check if a post already exists. This includes to check if the post exists as draft as well. But I struggle a little bit with the wordpress API v2. http://v2.wp-api.org/reference/posts/ Under ...
2
votes
2answers
2k views

Get blog title with REST v2

I can't find the answer after searching, so... How do I get the title of a site using the REST API v2? All I can find in the API docs are the posts, pages, tags,...
2
votes
1answer
3k views

Wp Rest Api Custom Endpoint for page subpages

I'm tring to add a custom endpoint for a page subpages. Parent Page ID = 151 function list_subpages( $data ) { $subpages = get_pages( array( 'child_of' => $data['151'], ) ); if ( ...
2
votes
0answers
23 views

CORS & Remote access to WP via RestAPI

I have built an app which enables the manager of many WP sites to make RestAPI GET, POST, PUT & DELETE requests which work perfectly when using them from this Apps, when the WP site are hosted on ...
2
votes
0answers
30 views

How to filter Post using Meta Data REST API

I want to list post that filtered by Meta Data I have tried many solutions i found here but i can't make it work. The last solution i tried is to add this to my functions.php add_filter( '...
2
votes
1answer
40 views

Options to get my custom post type metadata via the WordPress API

I am using a plugin that adds multiple custom post types all of which have their own meta-data. I am able to expose the custom post type to WordPress's API but the metadata collected with those post ...
2
votes
0answers
65 views

Limit REST API output to current logged in user that is also author of the content

https://developer.wordpress.org/rest-api/using-the-rest-api/frequently-asked-questions/#require-authentication-for-all-requests This requires authentication for all reque​sts. add_filter( '...
2
votes
0answers
71 views

Wordpress API returns empty page when page is less than X-WP-TotalPages

I am querying in the Wordpress API for all pages of media attachments. I am going page by page. I have about 5800 pages and when I hit pages 50-53 they return a blank or more of a [] but it is a ...
2
votes
0answers
51 views

Extending wp JavaScript base class to make a post request to a custom REST endpoint

I've defined a REST endpoint /my-plugin/v1/post-read to show whether a post has been read or not, per-user. In PHP, my plugin keeps track of this depending on page views while logged in. I'm now ...
2
votes
1answer
267 views

Flush Rewrite Rules on init or rest_api_init?

if I'm using the REST API to create endpoints in my plugin, should I be flushing rewrite rules on init or in rest_api_init? I realize that it should be done on plugin activation/deactivation. However,...
2
votes
0answers
21 views

Getting a Meta from Multiple Meta [duplicate]

i want getting a meta value from multiple meta i getting meta by : $data['cd_meta'] = get_post_meta( $p->ID, 'cd_meta', true); but cd_meta is a multiple meta and i need just one specific meta ...
2
votes
0answers
83 views

Rest API and Custom Fields

how can I create a new post post (custom type, with custom fields) on the front end using rest api and an http request? Is this even currently possible to create a new post with custom fields through ...
2
votes
0answers
988 views

WP Rest API max limit include parameter?

I'm using the rest API to get only selected posts though Rest API. I have used include=<ids> parameter. I have send the API request like: http://example.com/wp-json/wp/v2/posts?include=11,12 ...
2
votes
1answer
3k views

404/500 error on /wp-json

I get 500 error on wp-json. if I try to echo get_rest_url() I get example.com/wp-json, which then gives me error 500. I added RewriteCond %{REQUEST_URI} !^/wp-json to my .htaccess, which gave me 404 ...
2
votes
0answers
473 views

Full page NGINX (or Cloudflare) caching and WordPress nonces

Goal: I want to cache the full WordPress response via NGINX and exclusively use the REST API for the user specific parts. Issue: I can't get an authenticated nonce to use against the API. My plan ...
2
votes
2answers
126 views

How to build a child theme from a react-based parent theme?

I have a few years worth of experience building Child Themes in WordPress, which is generally my preferred route when developing a new website as I am not a theme developer per say. I am now doing a ...
2
votes
0answers
699 views

create new post using rest API and set featured Image from an external link

I am new to Wordpress. I need to create a new post from the Rest API which has its featured image from an external link. I can successfully create a new post using the rest API plugin, how do I add ...
2
votes
0answers
984 views

Is it possible to update a post meta field through REST API if the format of it when registered is nested?

I am able to get the custom REST API fields using meta key values to be formatted like this: "location": { "lat": "000001", "long": "000002" }, The works fine when I am trying to retrieve ...
2
votes
0answers
263 views

Remote REST request to check login status

There are 2 wp installations, A and B. Is it possible to do a remote rest request from site A to find out if an user is logged into site B? If yes, how? With this information adjustments would be ...
2
votes
1answer
4k views

Adding Wordpress API Endpoint With Multiple Parameters

So I understand for the most part how the wp rest controller works, what it is doing and why it is the best way to do it. The trouble I am having is wrapping my head around the regular expressions in ...
2
votes
1answer
335 views

Is it possible to nest the JSON result of Wordpress REST API?

I have been try to search around if it is possible to have a 'nested' JSON response in adding some custom fields through register_rest_field I have this code: function video_get_post_meta($object, $...
2
votes
0answers
60 views

WP REST- video and audio players

Im build VUE JS based theme, and Im using WP REST v2. And there is a problem, I can't make video and audio playlist working (build-in WP feature). I already added: wp_enqueue_style( 'wp-mediaelement' ...
2
votes
1answer
443 views

Permission Check for REST API Endpoint Runs Twice?

I'm making a plugin using the WP REST API, and everything seems to be working as expected. However, there is behavior I don't understand. The authPermissionCheck() method is executed twice for each ...
2
votes
0answers
189 views

How to filter users on custom meta fields in WP JSON v2?

I am trying to filter users on meta field, say abc is user meta field and value is 123 for user1. I have tried filter parameter with WP query like parameters, but it returns all users. 'search' ...
2
votes
1answer
2k views

Modify WordPress Rest Api Request/Response

I am building an application using WordPress Rest API. I want to make simple calls to the API, such as just /wp-json/wp/v2/posts and let the backend have a systematic way how to handle this and serve ...
2
votes
0answers
380 views

Prevent wp_insert_user from creating duplicate users

I have a custom plugin that automatically creates a new user via wp_insert_user() if the current user does not exist yet. We use data from our remote ldap server to provide the new user's details (...
2
votes
0answers
133 views

Login WordPress website using wp-rest api

I am using WordPress 4.8 and i am new to rest api . I have 2 websites , one is www.example.com and second is www.example.com/site2. That is second website is installed inside the first . In example....
2
votes
1answer
2k views

Recommended way to remove WP REST API returned data for custom post

I have been searching for the proper way to modify the returned responses for a custom post type. I have found a way to do it but the official documentation discourages this method. I personally don'...
2
votes
0answers
193 views

WP REST API returns incorrect data?

I'm trying to get a page from the API based on its page template however it seems to be returning incorrect data? so I'm unsure whether I am using the API correctly. http://domain.dev/wp-json/wp/v2/...
2
votes
0answers
512 views

How to make a WP REST API query with meta_query in WP4.7?

There is no "filter" parameter in WP REST API WP 4.7 and this call doesn't work: http://domain.tld/wp-json/wp/v2/cpt_name?meta_query[0][key]=cf_name&meta_query[0][value][0]=cf_value1&...
2
votes
1answer
656 views

WP API ignores filter parameter

I'm trying to return a list of posts or media via the Rest API But it seems that when a filter incorrectly specified then a whole page of results is passed back. So a curl command like curl -gv "...
2
votes
0answers
62 views

Keep user’s privileges on accessing contents in JSON response

I use WordPress REST API plugin to fetch WordPress stuff on a mobile app. What Access manager plugin keeps the privileges on REST API responses? I want restrict access to certain posts, categories ...
2
votes
1answer
4k views

How to generate HMAC-SHA1 signature to use with WP REST API and OAuth1

I'm trying to publish a post using WP REST API. I was able to authenticate using OAuth1 using the PAW http client. I was able to publish a post to the site as well (again using PAW). PAW generated ...

1 2 3
4
5
18