Tags - Listing and Searching Tags

Groundhogg provides the /tags/ endpoint. The tags endpoint allows users to query the tags table inside the  database  and lets you perform operations on tags. This endpoint supports GET, POST, PUT, PATCH and DELETE HTTP operations.

You can list all the available inside your Groundhogg instance by making a GET HTTP request to the tags API of Groundhogg. Make sure you added required 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"
}<br>

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 a GET request. It will return the select2 formate list of tags.

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

Searching tags

You can search for a specific tag by adding “search” or “q” arguments while making a request. it returns a list of tags that contains keyword from the 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"
}<br>
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us