how can I add an URL parameter to a rest route using register_rest_route()?
Regex problem, I found out 🙂 register_rest_route( ‘…/v1’, ‘import(?:/?url=(?P<url>\d+))?’, array(
Regex problem, I found out 🙂 register_rest_route( ‘…/v1’, ‘import(?:/?url=(?P<url>\d+))?’, array(
Well, you can add ?page={$page_number} to the URL that you’re requesting. See, for example, http://demo.wp-api.org/wp-json/wp/v2/posts/?page=2. It appears to split the posts into pages of 10. Reference WP-API documentation (I found this in the docs for v1 of the API, but per the sample URL above, it works on v2 as well)
GET request for media files in WP REST API 2 results in an empty array
You’re running the query but you’re immediately afterwards printing it out, you need to call the method get_posts or use something like a while statement with have_posts: https://codex.wordpress.org/Class_Reference/WP_Query
Take a look at this: https://jsfiddle.net/9j96jbxn/1/ Replace your data.forEach(function (element) {…} with a nested for loop. This should get you close to what you are looking for.
First (since 4.7.1) you will need to re-activate the filter parameter. Then make sure you have REST support activated for your custom post type (books). Next you have to allowing the query args meta_query and parse it. This answer shows how to do all this. Specifically, how to construct the meta query and the compare … Read more
The slash at the end is the culprit. While real requests with a / at the end of the route get wp_unslash()ed before resolving, the links for embeds do not. So, public function prepare_link_url ( $parts = array() ) { array_unshift( $parts, self::NSPACE ); return rest_url( implode( “https://wordpress.stackexchange.com/”, $parts ) ); } does the trick.
If i’ve understood the question correctly, this depends on the website you are trying to fetch data from. I would suggest you read the Term of service of the target site, and see if they have denied accessing/using their content by third parties. If the contents are not copyrighted and free to use, then there … Read more
I solved it. add_filter( ‘filter_rest_allow_anonymous_comments’, ‘__return_true’ ); should be: add_filter( ‘rest_allow_anonymous_comments’, ‘__return_true’ ); I found it by looking for the filter itself and saw that it was different than in the original answer.
Here is a good starting point if you are new to angularjs and WP Rest API with very brief and well documented code. https://github.com/michaelbromley/angular-wordpress-seed Cheers to Michael Bromley