Linking and embedding two custom post types with the REST API
Linking and embedding two custom post types with the REST API
Linking and embedding two custom post types with the REST API
The cURL error 28 you are encountering indicates that the cURL request used by wp_remote_get and wp_remote_post is timing out. In your case, it’s timing out after 10 seconds (10001 milliseconds) without receiving any response from the server. Here are a few steps you can take to troubleshoot and potentially resolve this issue: 1. Increase … Read more
Something like this should work: const {select, subscribe} = window.wp.data; const cartStoreKey = window.wc.wcBlocksData.CART_STORE_KEY; const unsub = subscribe( onCartChange, cartStoreKey ); function onCartChange() { const cart = select( cartStoreKey ).getCartData(); console.log( ‘¡ cart change !’, cart ); } The block’s frontend script should have the woocommerce script’s handle as a dependency so the window.wc.wcBlocksData will … Read more
Get list of outdated plugins in the rest api? It looks like you would need to create your own custom REST API endpoints using get_plugin_updates() and get_theme_updates() to list available updates. Note that these display cached data and don’t trigger a request to wp.org api.
As far as I can tell, that’s still not possible. getEntityRecords() uses the REST API, but that doesn’t support meta queries by default. You can follow ticket #47194 if you’d like to keep tabs on the request to add support, or contribute to it. For now, using rest_{posttype}_query seems to be the conventional way to … Read more
To pass the current post type to your AJAX request, you need to modify your JS to include the post type information in the AJAX request. You can achieve this by adding the post type as a parameter when calling the filterPosts() function JS import Alpine from ‘alpinejs’; Alpine.data(“filterPosts”, (adminURL, postType) => ({ posts: “”, … Read more
Maybe because the custom REST field (fimg_url) was only being added to posts of the post type and yet your request was for Pages, i.e. posts of the page type.. so try changing the register_rest_field( array(‘post’) to register_rest_field( array(‘post’, ‘page’). See https://developer.wordpress.org/reference/functions/register_rest_field/#parameters. But actually, you can use the _embed parameter to have the full media … Read more
Yes, the nonce is by default always being sent via the X-WP-Nonce header – see the source here and here on GitHub. wp.api.WPApiBaseModel.prototype.sync and wp.api.WPApiBaseCollection.prototype.sync can technically be extended or modified, but I would instead disable the nonce header like so, i.e. using <Collection or Model object>.endpointModel: Collection example: const Posts = new wp.api.collections.Posts(); // … Read more
Here’s how can you get the ID and email address of the author of the currently being edited post: // Get the post author’s ID. let postAuthorId = wp.data.select( ‘core/editor’ ).getCurrentPostAttribute( ‘author’ ); /* or you can also use this: let postAuthorId = wp.data.select( ‘core/editor’ ).getEditedPostAttribute( ‘author’ ); */ // Get the post author’s email. … Read more
✨ Explanation and Solution Updating the plugin to prevent standard output couldn’t be easier. No need to create a custom skin, WordPress already provides one for this case: Automatic_Upgrader_Skin Description: This skin is designed to be used when no output is intended, all output is captured and stored for the caller to process and log/email/discard. … Read more