WordPress Rest API query parameters mappings

This array defines mappings between public API query parameters whose values are accepted as-passed, and their internal WP_Query parameter name equivalents (some are the same). Only values which are also present in registered will be set.

Below is the list of all the endpoints which have query parameters mapping:

  • wp/v2/comments
  • wp/v2/<post-type>
  • wp/v2/<taxonomy>
  • wp/v2/<term>
  • wp/v2/<users>

Check below list of parameters mapping by Rest API endpoints:

wp/v2/comments

$parameter_mappings = array(
    'author'         => 'author__in',
    'author_email'   => 'author_email',
    'author_exclude' => 'author__not_in',
    'exclude'        => 'comment__not_in',
    'include'        => 'comment__in',
    'offset'         => 'offset',
    'order'          => 'order',
    'parent'         => 'parent__in',
    'parent_exclude' => 'parent__not_in',
    'per_page'       => 'number',
    'post'           => 'post__in',
    'search'         => 'search',
    'status'         => 'status',
    'type'           => 'type',
);

wp/v2/<post-type>

$parameter_mappings = array(
    'author'         => 'author__in',
    'author_exclude' => 'author__not_in',
    'exclude'        => 'post__not_in',
    'include'        => 'post__in',
    'menu_order'     => 'menu_order',
    'offset'         => 'offset',
    'order'          => 'order',
    'orderby'        => 'orderby',
    'page'           => 'paged',
    'parent'         => 'post_parent__in',
    'parent_exclude' => 'post_parent__not_in',
    'search'         => 's',
    'slug'           => 'post_name__in',
    'status'         => 'post_status',
);

wp/v2/<taxonomy>

$parameter_mappings = array(
    'exclude'    => 'exclude',
    'include'    => 'include',
    'order'      => 'order',
    'orderby'    => 'orderby',
    'post'       => 'post',
    'hide_empty' => 'hide_empty',
    'per_page'   => 'number',
    'search'     => 'search',
    'slug'       => 'slug',
);

wp/v2/<term>

       
$parameter_mappings = array(
    'exclude'    => 'exclude',
    'include'    => 'include',
    'order'      => 'order',
    'orderby'    => 'orderby',
    'post'       => 'post',
    'hide_empty' => 'hide_empty',
    'per_page'   => 'number',
    'search'     => 'search',
    'slug'       => 'slug',
);

wp/v2/<users>

$parameter_mappings = array(
    'exclude'  => 'exclude',
    'include'  => 'include',
    'order'    => 'order',
    'per_page' => 'number',
    'search'   => 'search',
    'roles'    => 'role__in',
    'slug'     => 'nicename__in',
);
Advertisements

Author: Mahesh Waghmare

I'm a professional WordPress theme/plugin developer since 2012.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.