Hi, I followed this tutorial to start counting post views in Frontity.
The request in every post view is working fine, however Iâm kinda lost as how to return the top 4 most-read posts.
The tutorial final step says âNow itâs easy to make a query for the most popular posts by including âmeta_keyâ => âviewsâ and âorderbyâ => âmeta_value_numâ as query arguments.â
But I donât know how to do this.
I need to retrieve the 4 most popular posts so I can list them in the homepage. It would be good too if I could get only recent (2 weeks ago to current day) posts, to achieve kind of a âtrending new postsâ effect.
I tried searching the docs but maybe Iâm searching for the wrong terms.
So I guess your url could look something like this:
https://[website]/wp-json/wp/v2/[post_type]?meta_key=[meta_key_name]&meta_value=[meta_key_value]&filter[orderby]=[meta_key_value]&order=desc
But maybe you already fabricated something like this as well and are just unsure on how to use the returned posts in Frontity. That I wouldnât know as well (yet).
Yes, this is really some work to do that is not directly Frontity related but more WordPress related. One of the challenges of working with Frontity is being able of getting the info we need of WordPress via REST API.
Besides the one you mention
Here you have some resources that may be helpful for this: