I’m using a modified plugin to do JSON web services from WordPress. The plugin you can get here. Here are some examples you can try…
Pull a specific article.
www.example.com/?json=get_post&post_type=news-and-articles&post_id=67
Pull all articles based on a given year.
www.example.com/?json=get_date_posts&post_type=news-and-articles&date=2014&count=5&page=1
Pull all recent articles
www.example.com/?json=get_recent_posts&post_type=news-and-articles&count=5&page=1
How pagination works is that the query string count is how many posts you want to show. The query string page signifies which paginated page you are on.
The web service will always provide you how many total paginated pages based on your count (pages) can be returned as well as how many total posts (count_total) there are.
So to paginate you would just bump up the page in the query string until you hit the max range specified in pages that you get from the JSON.
Attached is an example JSON post. I hope we can use these definitions which I’ll define below. Given this is the call: www.exape.com/?json=get_recent_posts&post_type=news-and-articles&count=5&page=1
- Status = status of the web service. {ok | error}
- Count = How many posts are in the current web service request.
- Count Total = How many posts total in the web service request.
- Pages = How many total pages of posts are available. Pages is basically the sum of count_total divided by the count rounded up.
- ID = Post ID
- Type = Post Type
- Slug = Permalink
- URL = URL of the article
- Status = The status of the post. { publish | draft }
- Title = Title of the Post with HTML
- Plain_Title = Title without HTML
- Content = Post content which will contain HTML. M-dash, r-quotes, © will be in the text as is.
- Excerpt = This is the short version of the content. If its not defined by the user, you will get first 20 words. Excerpt are under the same condition as content. It will contain HTML. Characters entities are as-is.
- Date = Date of when the post was first published
- Modified = Date of when the post was last edited
- Categories = The categories of the post
- Tags = Tags given to the post
- Author = Will contain author information. Can elaborate if needed. This is coming from the blog capabilities of WordPress
- Comments = Will contain comments. Can elaborate later if needed.
- Attachment = Still figuring this out. I believe this is where images, files, etc.. that are associated to the post will come from.
- Comment_Counts = Total number of comments
- Comments Status = If the post allows comments or not. {open | closed}
- Custom Fields = Other fields setup for the post.
- For the quote, need to know whether LDQUO and RDQUO will be sent and also whether they will be formatted or entities
>>Special characters will be in the HTML. They will not be converted into HTML entities.
- For the main News page, need to know whether you send the “truncated version” or the full article. Either is fine as long as it’s only 5 at a time (10 on page load)
>>You’ll get a truncated version of each article. WordPress calls it an “excerpt.” The full article is provided as well in case it is needed for SEO purposes. To do 5 at a time and 10 on page load since you want to preload the first pagination batch. I would first do a call like this on page load:
www.example.com/?json=get_recent_posts&post_type=news-and-articles&count=10&page=1
And then each time someone clicks on load more (other than the first since you preloaded it with the first batch of 5) you would bump the page count to 3 then 4 then 5.. and so forth with a count of 5. How high you can bump the page count to is defined in the JSON head under pages.
www.example.com/?json=get_recent_posts&post_type=news-and-articles&count=5&page=3
To make it easier for you, you just wouldn’t preload the second batch but just call the following on page load.
www.example.com/?json=get_recent_posts&post_type=news-and-articles&count=5&page=1
And every time someone clicks on the load more button you just call the same thing except bump the page to 2 then 3 and so forth…
- For the abstract (or content if sending whole thing), need to confirm that paragraphs will be wrapped in<p> tags regardless of whether there is more than one.
>>Yes they will be wrapped by <p> as a default.
- Person entering the article/release should be able to:
- add links (e.g., to product pages, author pages)
- add italics (preferably wrapped in <i> tags)
- add bold (preferably wrapped in <b> tags)
>>These are all possible. And they will not be escaped.
- Need to know whether user will be able to put anything like this in the article/release:
- lists (ordered, unordered, or both)
- subheads
- anything else besides plain text
>>All HTML is possible, but typically they will be links, unordered lists, heading, and image tags.
See the entire feed: