Search code examples
phpwordpresswordpress-themingwordpress-rest-api

Wordpress: how to use Wordpress post format with REST API


I'm building a blog for a mobile app have 2 post formats standard and video by using the WordPress function:

add_theme_support(
    'post-formats',
    array(
        // 'aside',
        // 'image',
        'video',
        // 'quote',
        // 'link',
        // 'gallery',
        // 'audio',
    )
);

This functions ads the formats widget on the post and shows the format field on the REST API at /wp-json/wp/v2/posts.

The issue is I can't filter posts by the format, I can't do the following for example /wp-json/wp/v2/posts?format=video


Solution

  • I went to use this plugin here and the rest API point becomes:

    /wp-json/wp/v2/posts?filter[post_format]=post-format-xxx