Questions tagged [wp-api]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
21 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
69 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
36 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
36 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
0answers
16 views

WP-API Yoast Default Site titles with snippet variables not saving

I’m using a headless WordPress with WP-API. So, I’m exposing yoast data in the API. With something like this: 'yoast_wpseo_title' => wpseo_replace_vars(get_post_meta($post->ID, '...
0
votes
0answers
19 views

External requests to authenticate Wordpress Rest API, with a private secret key

I want to validate the Wordpress Rest API for requests from two different domains. Wordpress, Cookie or O-auth methods can be verified. But it is impossible to accept external requests with Cookie. ...
0
votes
1answer
23 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
33 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
77 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
19 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) { $...
1
vote
0answers
30 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
112 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
65 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
32 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
22 views

Extended Custom Post type get all posts in wp-json

Using johnbillion/extended-cpts I try to figure out how can I have all posts in wp-json response. Till now what I tried did not worked I registered the post as it follows ...
0
votes
0answers
23 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&...
0
votes
0answers
32 views

REST API pages filter by slug redirecting on certain slugs

Im encountering a super weird issue when using the REST API. When fetching a single page by slug i use the following url: wp-json/wp/v2/pages?slug=XXX where XXX is the slug of the page. Now this ...
0
votes
0answers
12 views

Display index page to user from WP custom plugin

I want to write a simple plugin to display a maintenance mode page. How I can do this? Is there a specify wordpress API to display this page on front-end?
0
votes
0answers
21 views

How to create an relation between custom posts?

I have 2 custom post types : post (default cpt) and movie. Every movie have an imdb term that is an unique string for each movie. The post (default) can contains movies inside, so I'm using metabox to ...
1
vote
0answers
34 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
1k 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
0answers
20 views

Create new editable route/endpoint based on meta key

I'm currently making a store which is receiving it's data from external sources. Being new to the world of editing/creating REST API, I've come across a problem. The problem is that the external ...
0
votes
1answer
329 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
58 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
0answers
235 views

Upload Media using the WP API

I'm trying to create a plugin to allow me to upload media files to the media library using the WordPress API V2. I'm trying to use Filepond to do this but I'm facing a 401 unauthorized issue. plugin....
0
votes
1answer
913 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
102 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
0answers
93 views

filter by Meta custom field in rest api defined by pods as realtion to categories

i installed PODS and create a new custom post type named locations and relate it to default Wordpress entity : category when i call mydomain.com/wp-json/wp/v2/locations?fields=id,category rest ...
0
votes
1answer
26 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
213 views

Custom endpoint without loading entire Wordpress

With only WooCommerce installed the Wordpress rest api loading time is above 1.5s, this is unpractical, so i'm trying to create a custom endpoint and define SHORTINIT to true to load the minimum ...
0
votes
0answers
23 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 ...
1
vote
1answer
132 views

Can I list all installed plugins/versions and wp version from API

I would like to generate a simple text report for a Wordpress instance listing: Wordpress version Plugins installed (version and whether enabled) I can get this information from the Dashboard, but ...
0
votes
0answers
85 views

WP-API Content showing null

I am working on a decoupled theme for myself and I've worked with WP-API in the past and it was easy to get the post content. For some reason this go around I am having issues getting the content. I ...
0
votes
1answer
782 views

Woocommerce REST API not considering discounts and coupons

I am trying to create an order on my WooCommerce store from my mobile application using the REST API v2. The order is created successfully but I can't find any solution to the following issues. I ...
0
votes
1answer
97 views

Why is wp api returning old acf values?

I have a list of custom post types (Events) with ACF fields for start and end dates that I'm getting using WP-API. I'm using the fetch api to make the calls. I have the acf-to-rest-api plugin ...
0
votes
0answers
188 views

Extending the API I created to return category names

I created this api using a plugin called WP REST API Controller. But it didn't return custom taxonomy categories so I installed a plugin called WP REST API – Pure Taxonomies, it's returning category ...
1
vote
1answer
2k views

Update Line Item Meta Data - WooCommerce API

stuck trying to update line item meta fields I've attached to each line item. From a call to a particular order you an see the line item meta attached below: "line_items":[ { "id":...
2
votes
0answers
723 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 ...
0
votes
1answer
110 views

WooCommerce API Returns 401

very confused by how the rest api for WooComm is functioning. I understand how it should function, but it returns a 401 no matter what I do. My user is a super admin and has read/write permissions. ...
0
votes
0answers
85 views

Consume legacy rest api dependent upon WP API plugin

Is there any way to consume rest-api of WordPress plugins which were originally dependent upon the WP-API plugin in recent versions (v4.7 or later) of WordPress? In my case, I want to use the rest-...
0
votes
1answer
63 views

Hiding WordPress REST endpoints from public viewing using Basic Authentication

I have this function which register new endpoint. By default the end point is public. I'm using Application Passwords' plugin which create a basic authentication account, let's say Basic ...
4
votes
2answers
2k views

WP REST API only returning partial list of users

Started working with the WP REST API for the first time. Our ultimate goal is to dynamically load UI elements based on which user is presently logged in. However, my attempts to pull a list of all ...
0
votes
0answers
193 views

How to properly set a value to meta fields of a custom post type in WP-API/node-wpapi REST API?

I have a metafields that is assigned to a custom post which I added as a REST API field: $this->post_types = array ( 'post', 'location' ); foreach( array( 'field_1', 'field_2' ) as $field ) { ...
0
votes
1answer
534 views

rest_no_route on custom API endpoint wordpress

I've been trying to figure this out for the last day or so to no avail. I'm trying to create an endpoint to gather data from a set of tables. I'm trying to write it in OOP because I need to learn. ...
1
vote
0answers
17 views

Posting page on all subdomains

I'm just asking to see if anyone has done this or any ideas how it could be done. I have 11 Wordpress sites(on a network/multisite, 1 domain and 10 subdomains) that will grow. I'm in the process of ...
1
vote
1answer
65 views

Syntax for REST API to have bold formatted and multiple lines in product description [closed]

My description in the "Edit Product" GUI visual looks like: Description Features : Feature 1 Feature 2 I use the rest API to dump out the description and it looks like this: "description":"<p&...
0
votes
1answer
580 views

Why are <link rel> tags from the header showing up on my Wordpress site? [closed]

I am testing my new WP site. I wanted to see how it worked using a text-only browser, so I fired up "links" from my shell to visit the site. At the top of the page before my navigation menu, the ...
2
votes
2answers
6k views

How to update/insert custom field(post meta) data with wordpress REST API?

I am trying to add custom post data( post meta data) through wordpress API but I am getting difficulty while updating/adding custom post data. below is the code that am using. Code written in ...
0
votes
2answers
606 views

How can I list all installed plugins/themes/versions from CLI/API?

I would like to generate a simple text report for a Wordpress instance listing: Wordpress version plugins installed (version and whether enabled) themes and child themes installed (version and ...
1
vote
0answers
553 views

WP Rest get all by post within that category, by category name not by cat ID

I'm trying to display all posts within a specific category but by slug name not by cat id, below is what I've tried. http://centreformemories.org/blog//wp-json/wp/v2/posts?filter[taxonomy]=category&...