API List Pages

List pages allow you to display WP-API driven list content in your app with bonus features like favoriting.

For example, display a list of posts or pages from your WordPress site. You can also display custom post type content, such as books, products, or speakers.  This content is stored for offline use after viewing, and is typically faster than an iframe page.

Limitations of List Pages

API lists display read-only post content, they do not work with custom plugins or special content.

For example, an embedded form, slider, or custom gallery plugin will not work through the API. If you have anything other than read-only content such as a blog post, you should use an iframe page instead. (Visit Menus => add a WordPress/external link to your menu)

Create a List Page

To create a list page, in the App Customizer go to Custom Pages => Add New.

Choose “WP-API List” from the dropdown, and add your title and list route.

All API list pages only show for the app where you created them, so you won’t see the page you just created if you go to another app.

Default Featured Image

The small image next to your posts will be pulled from your WordPress featured image. To change this image, upload a file called default.png to your offline assets under the settings tab of the app customizer. Recommended size is 150x150px.

List Routes

A list route is any API endpoint with collection data, such as posts or pages. Here are a list of example endpoints:

  • http://mysite.com/wp-json/wp/v2/posts
  • http://mysite.com/wp-json/wp/v2/pages
  • http://mysite.com/wp-json/wp/v2/media
  • http://mysite.com/wp-json/wp/v2/comments
  • http://mysite.com/wp-json/wp/v2/categories

Some endpoints (such as users) require authentication. AppPresser does not have a way to handle authenticated endpoints at this time.

Custom post types and post meta data do not show up in the API by default.  View this article for help.

To add custom content to the list item display, you can use  template hooks.

Custom Route Parameters

The WP-API allows you to add parameters to your query to show custom results. For example, to show a certain category, you would add this url as your route:

https://yoursite.com/wp-json/wp/v2/posts?categories=40

The ’40’ at the end is the category term ID. You can do the same for tags by changing the parameter to ?tags=XX.  How to find the category or tag ID.

There are other parameters available, such as author, orderby, exclude, and more. For a full list, please see the  “Arguments” section here.  You can string parameters like this:

https://yoursite.com/wp-json/wp/v2/posts?categories=40&author=1&exclude=214

You would put that full url as the list route in your custom page.

For more information, please view  this blog post, and the WP-API documentation.