Not having access to the functions file, I can't add the function to add the featured image to the API so I need to use wp-json/wp/v2/posts?_embed. With javascript I believe it is ._embedded['wp:featuredmedia']['0'].source_url so I tried with php after using wp_remote_get, $post->_embedded['wp:featuredmedia'][0]->source_url but the error I am getting is : Cannot use object of type stdClass as array
I'm using WP API to get posts in my application and I'm trying to exclude some posts from query using filter[post__not_in]. after removing filter in WP 4.7, I'm using WP REST API filter parameter plugin to get it back. and it works for all parameters but for post__not_in it's not effecting at all, I still get all posts. I saw some closed issues about this on WP API repo on github, they said that post__not_in are not allowed for unauthenticated …
I am trying to use Application Passwords on Wordpress 5.9 for the development of a client app. The page https://www.example.com/wp-admin/authorize-application.php shows the Application Passwords confirmation prompt, but if I click generate "Approve the connection" for the app, an error is shown: "No Path provides a match between the URL and the requested method." I also tried to GET the path "/wp-json/wp/v2/users/me/application-passwords?_locale=user" that is supposed to answer the request, but it says 404 error. The base path for wp api works …
Imagine you have custom post types - Users. There are fields for each user as the post title, description, image, and rules. All titles are names of the Users and all they have Mr. before the names. What is the correct way and how to display all these fields via API in another site(not WordPress) but for the titles to exclude/strip the string Mr.?
I have an AngularJS site that is pulling in posts from WordPress via the plugin "WP REST API (WP API)". I am testing a site on both dev and staging subdomains, and the WP API works on both. However, when I visit one domain, and then switch over to another domain immediately afterward, then the dynamically-generated Access-Control-Allow-Origin is "stuck" on the previous domain to make the API calls. It's not until I refresh the page, that the response header updates …
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 getting the following error, Access to XMLHttpRequest at 'http://localhost:8888/bolb/wp-json/wp/v2/categories' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. It's not working on the postman too. But, it's okay if I use the same URL (http://localhost:8888/bolb) as the site …
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 send a coupon_lines array within the order object and when the order is viewed on the admin panel, it shows the coupon there but the order total is not affected at all. Then I decided to calculate the total and discounts based on the …
I want to use Wordpress REST API to get the posts that are inside a custom taxonomy created by the theme. The taxonomy is called "my_portfolio" but if I use this I have this response: {"code":"rest_no_route","message":"Nessun percorso fornisce una corrispondenza tra l'URL ed il metodo richiesto.","data":{"status":404}} Instead if I use "my_portfolio_category" I have 4 categories that are called: "photo", "video", "design", "web". I want to retrieve the posts inside the category "photos" but the only thing I managed to get …
I'm currently developing a Plugin in which I'm in need of retrieving information from a third-party plugin API. To authenticate my users, I am trying to use the vanilla authentication via cookie as explained in the official documentation, but every request is refused with a 403 rest_cookie_invalid_nonce code. I cannot understand what I'm doing wrong. My code: function makeRequest(){ $url = 'https://xxxxxx.com.br/wp-json/wcfmmp/v1/orders/'; $nonce = wp_create_nonce('wp_rest'); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'X-WP-Nonce:'. $nonce, 'Content-Type: application/json', )); $result …
I have a CPT with relations i made and i need the relations to be sent via API Request. i edited it already so i can now see all meta fields in the API request but i cant get the relations to show. Any help would be greatly appreciated!
I know from this post that I can get posts by tag name by just specifying a filter[tag] query parameter. And similarly with filter[category_name]. Is there a way to get posts that are not in a list of tags or categories for the purpose of excluding posts? I would prefer to do it with the name, or else I would have to make another request just to get the ID of the category, which would just slow down my overall …
So I've been working on trying to figure this out, but I can't seem to get the right answer or even find docs online regarding this issue, so I'm reaching out to the community to see if I can get some assistance. So I have the following RestRoutes class: class RestRoutes { private string $namespace; private string $resource; public function __construct() { $this->namespace = 'twitter/v1'; $this->resource = '/posts/'; $this->init(); } public function init(): void { add_action('rest_api_init', [$this, 'register_rest_route']); } public …
I'm using WP API to insert a custom post in Wordpress. The custom post is "property". What I now need to do is assign that post a "metadata" (DB table "wp_postmeta") At first I thought It was going to be easy like (I'm using Symfony Http class here): Http::withBasicAuth($user, $password)->post("{$endpoint}/property", [ 'date' => now(), 'status' => 'publish', 'title' => 'Test', //etc... 'meta' => [ 'custom_metadata' => 1234 ] ]); The custom property post gets created but the meta does not. …
I currently have this site - http://dev.5874.co.uk/scd-data/ where I have a dropdown which displays results from WP-API which I am pulling in through AngularJS. It currently combines the two sets of results as they're separate URL's, the results are in categories within a custom post type so if both posts are 'tagged' in the same category chosen they display twice. I need a way to combine the two sets of results but only showing one of the posts - I …
Using the WP API and Backbone-based JS client, I'm trying to update a post's metadata as follows: var parentId = 96; // the post id var metaData = new wp.api.collections.PostMeta('', {parent: parentId}); metaData.fetch() .done(function(data) { var someKey = data.findWhere({key: 'someKey'}); someKey.set('value', 'newValue'); someKey.save(); }); Everything works fine until the calling of save(), which throws the following error: PUT http://example.org/wp-json/wp/v2/posts/undefined/meta/1901 404 (Not Found) Trying to sync the collection also fails. Any thoughts? Thanks!
I was using the below API to fetch all posts http://example.com/wp-json/wp/v2/posts/?filter[posts_per_page]=-1 Since the last two days, all of a sudden it stopped working. For example, the first API used to give me 37 records with 10 records per page, but now it only gives me 10 records instead of 37. It does not return records for rest of the pages. I checked the WordPress site from where I am trying to fetch it, it still has 4 pages and 37 …
I would be very grateful for your help. Already racked my brain for today! So, I used the CPT UI plugin and created my custom post type with it. Immediately when setting it up, I enabled RestAPI support (I always do this), and I also used the default WP_REST_Posts_Controller setting. When I give the command to add the default Post var review = new wp.api.models.Post( { title: 'Test post' } ); review.save(); everything is fine! But when I try to …
I have been trying to create a theme customizer to change the font size. To do that I have created settings and control. But the issue is I am unable to achieve like as shown in the image. I have used the range input type to adjust the value and it updates according to the increased or decreased value. I want to have a slider with a box that indicates the value and can be used to change the value …