-1
Good, I want to search for a random post of the articles but it always gives me the same article.
wp-json/wp/v2/fatos_random? filter[orderby]=rand&per_page=1
Thanks for the help
-1
Good, I want to search for a random post of the articles but it always gives me the same article.
wp-json/wp/v2/fatos_random? filter[orderby]=rand&per_page=1
Thanks for the help
0
You need to use the Rand() function, stating the parameters you need... the example below lists a single item ranging from 1 to 15. Then only link Rand to its variable $per_page
rand(1, 15);
Source documentation: https://www.php.net/manual/en/function.rand.php
Browser other questions tagged php ajax json wordpress
You are not signed in. Login or sign up in order to post.
But there’s no way to do it through the URL if I don’t have to load all the facts and only then choose one.
– Jorge Ferreira