List Query

Get a list of contacts, groups or another post type, with filtering and sorting parameters

Endpoint

GET https://example.com/wp-json/dt-posts/v2/{post_type}/

Parameters

sort (string)

  • Options:

    • name //name or title of the record

    • post_date //creation date of the record

    • any field_key

Add a - before any of these options to return them in descending order

Example:

// get records assigned to me, ordered by creation date from newest to oldest
let searchParameters = {
  assigned_to: [ 'me' ],
  sort: `-post_date`
}

user_select

Parameters: (array) of presets or ids.

  • me // records assigned to the user making the query

  • 83 // records assigned to user of ID 83

  • -84 // exclude records assigned to user 84

Example:

key_select, multi_select, tags

Parameters: (array) of keys.

  • overall_stats (key_select)

  • milestones (mutli_select)

  • gender (key_select)

  • tags (tags)

  • etc

Example:

connection

Parameters (array) of IDs

  • subassigned

  • groups

  • etc

Example:

Example:

Example:

Example:

location

Parameters: (array) of location_grid IDs

  • location_grid

Example:

date

Parameters: start and end

  • created_on // date the record was created

  • baptism_date

  • etc

Example:

boolean

Parameters (array). "1" for true, "0" for false

  • requires_update

  • etc

Example:

number

Parameters (array):

  • operator options: <, >, <=, >= or =

  • number

Field examples:

  • baptism_generations

  • quick actions

Example:

text communication_channel

Parameters: (array) or text to search for.

  • contact_phone

  • name

  • nickname

  • etc

Examples:

  • text (string).

  • fields_to_search (array). Default is ["name", "comms"].

fields_to_search options:

  • all

  • comment

  • name

  • text_field_key // any text field key

  • comms //communication channels

Example:

Combining with AND/OR logic

Wrapping parameters in arrays with switch add AND/OR logic. The first level of values has AND logic. Wrapping them in an array gives them an OR logic. 1st layer: AND 2nd layer: OR 3rd layer: AND etc

Note that the query is sent in the fields array and thath the structure is a bit different.

Examples:

Recently viewed posts

dt_recent (bool) true. Cannot be combined with other parameters except: fields_to_return

Example:

Paging Parameters

offset (integer) the number of records to skip. Optional. limit (integer) the number of records to include in the response. Default is 100, Maximum: 1000. Warning: a large number may cause a server memory error. Optional.

Example:

Specifying and limiting returned fields

fields_to_return (array) the fields to return. Optional.

Example:

Bringing it all together

After building the filter parameters, we need to transform the searchParameters object in the query parameters string. The query string needs to be the same format that jQuery.param() outputs. See here for a plain js alternative

Returns

Last updated

Was this helpful?