arthur-eudeline
9/3/2018 - 8:45 AM

WordPress - AngularJS 1

WordPress service - AngularJS (v1)

Use this service to interect with a WordPress website and a mobile app or a WordPress SPA theme for exemple.

Query default arguments

There are the defaults arguments of WordPress rest API query. You can see them by going at {your_website}/wp-json/ and look at routes and finaly /wp/v2/{post_type}. Find the object endpoints.methods.args.

var defaultArgs = {

    // {string} Context of the resquest ; query result can include more field in terms of context. (view, embed, edit)
    "context"           : "view",

    // {int} Current page number in the query results
    "page"              : 1,

    // {int} Number of results per page
    "per_page"          : 10,

    // {sting} Search terms
    "search"            : "",

    // {srting|datetime (yyyy-mm-dd hh:mm:ss)} published AFTER a date
    "after"             : "",

    // {srting|datetime (yyyy-mm-dd hh:mm:ss)} published BEFORE a date
    "before"            : "",

    // {array[int]} Include content published by authors by their ID
    "author[]"          : [],

    // {array[int]} Exclude content published by authors by their ID
    "author_exclude[]"  : [],

    // {array[int]} Include content by their ID
    "include[]"         : [],

    // {array[int]} Exclude content by their ID
    "exclude[]"         : [],

    // {int} Number of results to pass over
    "offset"            : 0,

    // {string} Order of the results
    "order"             : "desc",

    // {string} Ordering de the result by a specific property (author, date, id, include, modified, parent, relevance, slug, include_slugs, title)
    "orderby"           : "date",

    // {string} Limits the results by using the slug of a content
    "slug"              : "",

    // {string} Limits the results by the status of the content queried (publish, future, draft, pending, private, trash, auto-draft, inherit, request-pending, request-confirmed, request-failed, request-completed, flamingo-spam, any)
    "status"            : "publish",

    // {array[int]} Array of categories ID that need to be included into the results. Can use the form "{custom_tax_slug}"
    "categories"        : [],

    // {array[int]} Array of categories ID that need to be excluded of the results. Can use the form "{custom_tax_slug}_exclude"
    "categories_exclude": [],

    // {boolean} If we need to ONLY query content that is sticky
    "sticky"            : false

};