Home » Php » php – fetch popular posts in wordpress with api

php – fetch popular posts in wordpress with api

Posted by: admin February 25, 2020 Leave a comment

Questions:

how fetch popular posts from WORDPRESS web site to PHP web site with rest API .

I fetched the last 5 posts via this script:

    // get dynamic blogs from WordPress
    $json = file_get_contents('https://my-web-site.com/wp-json/wp/v2/posts?per_page=5');
    $posts = json_decode($json);

Is there a way to fetch popular posts?

How to&Answers: