Custom Post Types and Post Meta

If you are using a WordPress list page that fetches posts from the WP-API, and you want to use a custom post type, or custom plugin data, you need to write some custom code in a WordPress plugin.

In the example below, we will show how to display events from the Events Calendar plugin.

The WP-API doesn't support custom post types or post meta by default. Adding them is just a few lines of code, we have a sample plugin file to help.

Please view the Gist here.

You will need to edit this file, all of the functions are commented out by default. Please read through the code, make any changes necessary, then add it to your site as a plugin.

Here's a video showing how to add events from the Events Calendar plugin.

The code for this example is here.

For more information on adding custom data to lists using template hooks, see  this article.

For more information on customizing the WP-API, please see these articles:

AppPresser 3 Feature Spotlight: API driven list pages

Add CPTs to the WP-API

Post meta in the WP-API