GET Method

GET method used to get a list of tags from Groundhogg. Users can retrieve all available tags by making a GET request to the following URL. Make sure you added require header parameters before making a request.

http://yoursite.com/wp-json/gh/v3/tags
{
    "tags": [
        {
            "tag_id": "5",
            "tag_slug": "confirm",
            "tag_name": "confirm",
            "tag_description": "",
            "contact_count": "1"
        },
        {
            "tag_id": "4",
            "tag_slug": "user",
            "tag_name": "user",
            "tag_description": "",
            "contact_count": "1"
        },
        {
            "tag_id": "3",
            "tag_slug": "client",
            "tag_name": "Client",
            "tag_description": "",
            "contact_count": "3"
        },
        {
            "tag_id": "1",
            "tag_slug": "administrator",
            "tag_name": "Administrator",
            "tag_description": "",
            "contact_count": "2"
        }
    ],
    "status": "success"
}

Searching tags

You can search for a specific tag by adding “search” or “q” arguments while making a request. it returns an output which contains that query string.

http://yoursite.com/wp-json/gh/v3/tags?q=administrator
{
    "tags": [
        {
            "tag_id": "1",
            "tag_slug": "administrator",
            "tag_name": "Administrator",
            "tag_description": "",
            "contact_count": "2"
        }
    ],
    "status": "success"
}

List of tags for select

Users can easily bound all the available tags in dropdown by setting select parameter true. It will return a list of tag’s id and tag’s name with the contact count.

http://yoursite.com/wp-json/gh/v3/tags?select=true
{
    "tags": {
        "1": "Administrator (2)",       
        "3": "Client (3)",
        "4": "user (1)",
        "5": "confirm (1)"
    },
    "status": "success"

List of tags for select2

Users can also bound tags inside a select-2 drop down by setting select2=true while making GET request. It will return the select2 formate list of tags.

http://yoursite.com/wp-json/gh/v3/tags?select2=true
{
    "results": [
        {
            "id": "5",
            "text": "confirm (1)"
        },
        {
            "id": "4",
            "text": "user (1)"
        },
        {
            "id": "3",
            "text": "Client (3)"
        },
        {
            "id": "1",
            "text": "Administrator (2)"
        }
    ],
    "more": false
}

Was this article helpful to you? Yes No

How can we help?