AJAX requests are used to fetch the news from the website. The plugin then returns all posts in a specific category. Seven ‘fields’ are returned in the JSON.
- post_title – The title of the post.
- post_content – The full content of the post.
- post_excerpt – A short excerpt of the post if it’s enabled in WordPress
- post_author – Author of the post. This can be either the actual login name or nickname of the author.
- post_time – Time the post was created. This can easily be change in WordPress when the post is created.
- post_gm_time – Post GMT. The actual GMT of when the post was created.
- post_link – A HTTP link back to the post. This allows you to create a ‘read more’ link when using excerpts.
Processing the JSON in C3 is a couple of loops where each post is looped through and then each of the above keys is looped through. In the example below, each key’s value is assigned to a local function variable. After the keys and values of the post are found, HTMLElement.Insert is used to place each one in the HTMLElement in the order desired.