WordPress API – Get Drafts
I think the query parameter that you want for post status is: status=draft Let me know if this doesn’t work.
I think the query parameter that you want for post status is: status=draft Let me know if this doesn’t work.
This is because the rest API internally uses json_encode() to output the data. There are 2 ways that you can resolve this. 1. Prevent the API from sending the data This might be a bit odd and raise some issues, but you can set the header type and echo the content before returning the data: … Read more
If you’re using WP 4.7+ you can filter the query using the rest_$type_query hook wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:L267 This is a working example that filters current query by given terms $types = [ ‘post’, ‘page’, ]; foreach ( $types as $type ) { add_filter( ‘rest_’ . $type . ‘_query’, ‘filter_rest_query_by_zone’, 10, 2 ); } function filter_rest_query_by_zone( $args, $request … Read more
Yes, the REST API is in the same location, just append /wp-json to the end of a site/blogs URL and there it is As for the network admin, at the moment there are no endpoints explicitly for multisite, so you can’t use the REST API to create and destroy sites without building those endpoints yourself, … Read more
Yes, pre_get_posts runs for REST API requests. Your issue is likely that your request is not properly authenticated, so $user_ID is not set. To allow the REST API to recognise the logged-in user you need to send the wp_rest nonce with the request. You can create this with wp_create_nonce( ‘wp_rest’ ) and send it with … Read more
function checkApiAuth( $result ){ $yourEncryptAPIKey = $_GET[‘request’]; if( yourDecryptFn( $yourEncryptAPIKey ) === $realKey ): $result = true; else: $result = false; endif; return $result; } add_filter(‘rest_authentication_errors’, ‘checkApiAuth’);
Block editor blocks are dynamically constructed by parsing the HTML of post_content. Blocks are delimited by HTML comments that looks like these: <!– wp:image –> <figure class=”wp-block-image”><img src=”https://wordpress.stackexchange.com/questions/359758/source.jpg” alt=”” /></figure> <!– /wp:image –> The way the actual data of blocks is stored depends entirely on the block. Blocks can either store their attributes inside the … Read more
There is nothing in the core or in the rest API for this requirement. You can try this plugin, https://github.com/remkade/multisite-json-api Sorry, but I see no other chance and no more to say in this answer. The core function to create a new site in the network of the installation is wpmu_create_blog. But there is no … Read more
The collection params accessed via that filter appear to describe the available query params but are not actually used in the query. I think what you actually want is the rest_{$this->post_type}_query filter which allows you to modify the args before they are passed to WP_Query::query(). Also keep in mind that on the API request the … Read more
Getting user names and passwords is a horrible idea I hope no user will actually agree to, but beyond that your idea to do it from JS is going to fail due to CORS, which means you will have to do it in AJAX to your server, and let your server try to login, which … Read more