Custom Filter

This API allows to add, view, and delete custom filter.

Custom Filter Properties #

AttributeTypeDescription
filter_labelstringLabel of Custom Filter.
hierarchicalbooleanSet 1 to make the custom filter behave like “post category”. Otherwise, it will be similar to a “post tag”.
show_admin_columnbooleanSet 1 to allow the automatic creation of taxonomy columns on the trips table.

Add Custom Filter #

This API helps to add a custom filter.

POST

/wp-json/wptravel/v1/add-custom-filter

curl --location 'https://example.com/wp-json/wptravel/v1/add-custom-filter' \
--header 'Authorization: Basic <application-key>' \

--form 'filter_label="Trip City"' \
--form 'hierarchical="0"' \
--form 'show_admin_column="0"'
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic <application-key>");

var formdata = new FormData();
formdata.append("filter_label", "Trip City");
formdata.append("hierarchical", "0");
formdata.append("show_admin_column", "0");

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: formdata,
  redirect: 'follow'
};

fetch("https://example.com/wp-json/wptravel/v1/add-custom-filter", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
<?php
$client = new Client();
$headers = [
  'Authorization' => 'Basic <application-key>'
];
$options = [
  'multipart' => [
    [
      'name' => 'filter_label',
      'contents' => 'Trip City'
    ],
    [
      'name' => 'hierarchical',
      'contents' => '0'
    ],
    [
      'name' => 'show_admin_column',
      'contents' => '0'
    ]
]];
$request = new Request('POST', 'https://example.com/wp-json/wptravel/v1/add-custom-filter', $headers);
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();

Delete Custom Filter #

This API helps to delete a custom filter.

DELETE

/wp-json/wptravel/v1/delete-custom-filter?filter_label=Trip City

curl --location --request DELETE 'https://example.com/wp-json/wptravel/v1/delete-custom-filter?filter_label=Test%20City' \
--header 'Authorization: Basic <application-key>'
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic <application-key>");

var requestOptions = {
  method: 'DELETE',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://example.com/wp-json/wptravel/v1/delete-custom-filter?filter_label=Test City", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
<?php
$client = new Client();
$headers = [
  'Authorization' => 'Basic <application-key>'
];
$request = new Request('DELETE', 'https://example.com/wp-json/wptravel/v1/delete-custom-filter?filter_label=Test City', $headers);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();

Get Custom Filters #

This API helps to get custom filters.

GET

/wp-json/wptravel/v1/get-custom-filters

curl --location 'https://example.com/wp-json/wptravel/v1/get-custom-filters'
var requestOptions = {
  method: 'GET',
  redirect: 'follow'
};

fetch("https://example.com/wp-json/wptravel/v1/get-custom-filters", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://example.com/wp-json/wptravel/v1/get-custom-filters',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

JSON Response

{
    "Test Filter One": {
        "label": "test-filter-one",
        "hierarchical": "1",
        "show_admin_column": 0
    },
    "Test Filter Two": {
        "label": "test-filter-two",
        "hierarchical": 0,
        "show_admin_column": 0
    }
}