WP JSON API get several posts using their slugs

I have had that problem. I am using a plugin known as “Top Ten” to generate the most viewed posts. However, this plugin does not generate the posts “the WordPress way” and I am unable to retrieve a well formatted JSON output when I access a page with it. This made me decide to have a look at alternatives.

I realized I could generate the post links using this plugin. Thus, I decided to generate just the links and somehow use these links to generate a JSON response. I looked at JSON API and I found something interesting, that one can generate posts using the get_posts method. The documentation went further to state that “check WP_Query documentation for the full list of supported parameters” and at WP_Query documentation, I found something that I could use: post_name_in(String [] slugs). This caught my attention, but I have no idea how to implement this from JSON API.

Read More

In short, what I’m looking for is a way to achieve something like this: http://example.org/?json=get_posts&slugs=[slug-one,slug-two,slug-n]. Any help will be appreciated. Thanks.

Related posts

Leave a Reply