Questions tagged [wp-api]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
23 views

Post body not working with wp_remote_post()

I'm trying to post with with the following code $userTokenApi = 'https://api.mindbodyonline.com/public/v6/usertoken/issue'; $args = array( 'headers' => array( 'Content-...
0
votes
0answers
56 views

403 error rest_'cookie_invalid_nonce' on API Request

I'm currently developing a Plugin in which I'm in need of retrieving information from a third-part plug-in api, to authenticate my users I am using the trying to use the vanilla authentication via ...
0
votes
0answers
25 views

How to use following API with WordPress?

I have an old client who wants to integrate one system on their WordPress website. The company is fairly new called LYFSIZE which basically takes the picture of the users and provides them the exact ...
0
votes
1answer
31 views

Uploading a media item with the wp-json API to a specific path

I'm using the WP-JSON API to import all my posts from my live site to my development site. It's working fine for posts, categories and authors, but when I upload my images, the API treats the files as ...
0
votes
0answers
20 views

Help to create the best plugin settings!

Can you help me about how to create the best WordPress settings for plugins? I have a custom setting page and I need to create some field with WordPress API. Actually I use this solution: https://gist....
0
votes
0answers
21 views

Remove unwanted fields from WP API response

I am making a mobile app that links to a Wordpress site. There are a lot of unwanted data from the API response and it would be great if I could remove it. How could I do that without touching the ...
0
votes
1answer
62 views

WordPress REST Api get posts by ID

Hi I'm building up a WordPress rest API's custom endpoint on my project. I'm using the following code to get the single response from the website. function get_single_post( $request ) { $...
0
votes
2answers
28 views

WP Rest API get page from path

I am looking to use the rest API to use WordPress as a headless CMS, but I am curious as to how best to get a page using the path. Example, if Wordpress is hosted at cms.example.com and my frontend ...
0
votes
1answer
22 views

How to add a post's view count into the WordPress API response

This is my first time working with Wordpress APIs, and i'm not a PHP developer. Essentially our client just wanted us to display WordPress articles in our react-native app with simple data like the: ...
0
votes
1answer
36 views

post values to custom post type which has advanced custom fields

I am trying to use Ajax and jQuery to post data to a custom post type. The title field works as is standard wordpress field but the color field does not. I also tried replacing 'color' with the name ...
0
votes
1answer
46 views

Creating a WordPress Post via REST API - HTML or Markdown?

When creating a post using the WordPress REST API, should the post body content include HTML or should the post body content be written in Markdown language? Or can it be either? I'm looking to ...
0
votes
0answers
22 views

No 'Access-Control-Allow-Origin' when call rest API

I am using ReactJs with WordPress. WordPress running on localhost 8888 port and React app running on 3000 port. When I change the WordPress site URL (from settings->general) to localhost:300 then I am ...
1
vote
1answer
20 views

I am getting error message on accessing menu-endpoint

I am trying to access wordpress menus using the /wp/v2 api. The endpoint that I am using is: My wordpress Staging Site's WP-API Endpoint The Plugin I am using is: https://wordpress.org/plugins/wp-...
0
votes
1answer
40 views

Custom REST endpoint not working to retrieve single posts (“rest_no_route”)

I've got the following basic route for my custom REST endpoint: add_action('rest_api_init', 'my_cpt_route'); function my_cpt_route() { register_rest_route('mytheme/v1/', 'my_cpt', array( '...
0
votes
1answer
119 views

wordpress custom endpoint multiple params

I'm trying to create a route in my store, to receive notifications from an API, but every time I test the route I created, I get this error message No route was found matching the URL and request ...
1
vote
0answers
21 views

Woocommerce api: create product with images - bad request

I am trying to create a product with images via the Woocommerce Rest API but I get bad request: Here is how I am preparing the images array: //IMAGES $images = []; //Get the featured image ...
1
vote
1answer
50 views

Adding custom end points, No error line

I have been trying to implement a custom end point that inserts data from my mobile application into this database. However, I cant seem to find the correct way to do it. Some places used #wpdp->...
0
votes
2answers
100 views

How to run wp cli from a wp hook?

How can I run a wp cli command when a wordpress hook is called on my website. On user registration hook, I would like to run a wp cli command to activate a license.
0
votes
1answer
60 views

Wordpress API “code”:“rest_no_route” with Custom Route

I am attempting to start creating a custom endpoint for one of my sites, so I can pull in ACF fields to another. I have the following code in my theme's functions.php // register the endpoints ...
1
vote
1answer
91 views

backbone fetch() not working

I'm trying to use the REST API with Backbone in a plugin. I'm working through the documentation and examples at: https://developer.wordpress.org/rest-api/using-the-rest-api/backbone-javascript-client/....
0
votes
0answers
18 views

WordPress Api only Custom Post Type

I want to make an app for a leafletting company where WP API will be used. all registered users will enter their leaflets details in a custom post type with their name, date, area and the number of ...
0
votes
1answer
21 views

Adding Amchart Interface to Wordpress API

I'm using the amchart wordpress plugin and want to add support for it via the wp rest API. Here's what I've done so far: in ../includes/setup.php (To $args array I've added: This will create the /...
0
votes
0answers
70 views

How do I allow CORS from my mobile application to my WordPress backend?

I am using WordPress Contact Form 7 plugin to send message from my mobile application. Of course testing with PostMan worked with no issues but as soon as I tried to post to the endpoint from my ...
1
vote
0answers
134 views

Hiding API routes list

When you go to /wp-json or /wp-json/[namespace] on an API-enabled WordPress site, it shows all of the API routes and endpoints. How can I disable this behaviour without disabling the REST API?
1
vote
0answers
49 views

Using WP-API and SSE not authenticating user ID

I am using the wp-api to create a custom endpoint for my data: add_action( 'rest_api_init', function() { register_rest_route( 'mb/v1', '/sse/', array( 'methods' => 'get', ...
0
votes
0answers
18 views

Adding get_results to wp rest api

I got custom function where I retrieve guid's attached to each post. Now I want to add this on WordPress API. global $wpdb; $post_id= $object['id']; $sql = "SELECT post_content FROM wp_posts WHERE ...
2
votes
0answers
123 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 ...
0
votes
0answers
62 views

wp_remote_get, how to update dynamically

please i want the ETHBTC price to be updating dynamically without refreshing the page,, if i use (meta http-equiv="refresh" content="5") it refresh the site. i want only the ETHBTC price to be ...
1
vote
0answers
24 views

Update a post based on results from GET request to another server

I need to use GET requests to retrieve the current status of a device and then update the body of a specific Wordpress post with the text data sent by the external device (for reference, it will use ...
0
votes
1answer
472 views

Get a remote post ID via API given URL

Given you have a URL, how can you get the post ID of a post on a remote WordPress site? As far as I can tell, you would have to: HTTP GET /wp-json/v2/posts And then look for your URL, but the ...
0
votes
2answers
1k views

Gutenberg Custom Block Getting All Posts

I'm trying to create a custom block but I need some assistance. I'm attempting to setup a <select> in the editor that lists all the posts. I'm not very experienced at the api yet but after ...
0
votes
0answers
453 views

Deleting media using the Wordpress Rest API

I am trying to delete a media object from my Wordpress instance using the Wordpress API in Postman. I'm having trouble finding the endpoint according to the documentation. Here is my http method and ...
0
votes
1answer
991 views

Can we access the REST request parameters from within the permission_callback to enforce a 401 by returning false?

From what I have tried and tested so far, the getters and setters do not work inside the function permission_callback. The alternate way would be to throw a custom 401 from the callback itself. Is ...
0
votes
1answer
28 views

wordpress api make 2 custom post type with single request

i have messenger chatbot and if the user click Get Started i make singel api call with $sender_id as title to add new post to my CPT inquery and when i look to wordpress panel i see 2 of them with ...
0
votes
1answer
46 views

Updata Metadata WP Rest API

I am trying to update a metadata I created from the front-end with a click event. { "id": 1248, . . . "metadata": { "wishlist_array": [ "" ], . . . ...
0
votes
1answer
833 views

Update Custom Post Type Metadata Wp Rest API

I am trying to update a custom post type metadata on the front end using JS and the WP Rest API. The object key is wishlist_array under metadata Here is how JSON response from http://ohalocal.local/...
0
votes
1answer
125 views

How to add a rest field to post tags?

I'm doing a headless wordpress, so using wordpress API. Using Yoast, I've added yoast SEO data to my post types API endpoints like this: function wp_api_encode_yoast($data, $post, $context) { $...
3
votes
0answers
367 views

Wordpress REST API “rest_authentication_errors” doesn't work external queries?

Wordpress REST API "rest_authentication_errors" doesn't work external queries? I was using following experimental codes for experimental purposes. add_filter('rest_authentication_errors', 'auth'); ...
2
votes
2answers
1k 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/...
1
vote
1answer
219 views

How to add WP API and JS featured image attachment

I would like to fetch the image from the wordpress rest api - I have the following code: HTML: <div class="post-item"> <div id="posts">Loading posts... </div> Ajax script: <...
1
vote
0answers
171 views

No featured media in API request

when I make a request to http://localhost/wordpress/wp-json/wp/v2/posts/?_embed&categories=${categoryId}&per_page=${state.perPage} I get the following result [ ...
0
votes
0answers
59 views

How to use the WordPress API to get links and scripts in <head> and <body>

I'm using the WordPress API as a headless CMS. I have Elementor plugin installed to do page building in the WordPress admin. I'm trying to figure out how to get all of the <link> and <script&...
2
votes
0answers
59 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 ...
0
votes
1answer
5k views

How to use Python to create a Post in Wordpress?

I found the API reference here: https://v2.wp-api.org/reference/posts/ Based on the API reference above, I wrote this Python code: from urllib.request import Request, urlopen from datetime import ...
0
votes
1answer
1k views

Wordpress API for custom post types returns rest_no_route

I created a custom post type and I am trying to get the posts from it using WP-API, however, when I try to access the API I get the error rest_no_route message. The set up for my custom post type is ...
0
votes
1answer
291 views

wp_insert_user if user exists

I have been at this for almost two hours, i'm sure i'm close, but can't find the nudge to make it work. I built a module from scratch to import users from a csv file, the user creation is working fine,...
0
votes
1answer
3k views

Add media with WP-Rest-API v2 II

I am having this exact question, asked in 2015, about adding media through the WP REST API. My code so far: curl -s -X POST http://www.example.com/wp-json/wp/v2/media/ -H "Content-Type: ...
1
vote
0answers
350 views

Custom Post Type not showing in Rest API on Multisite

I'm using WP Multisite and can't seem to pull through my custom post types via the API. <?php function terms_post_type() { $labels = array( 'name' => _x( 'Policies', '...
0
votes
1answer
108 views

Core function to check if a rest namespace exists

Does WordPress have a core function that will check if a rest namespace exists? I would like to use the following function (or something similar) in multiple plugins so it would be helpful if there ...
0
votes
0answers
35 views

Create Posts from API response without duplicates

I am hoping someone can help with this. I am getting content via an API call to a third party vendor that supplies articles. I need to then add these articles as posts and also make sure I don't ...