package wordpress import ( "encoding/json" "federated.computer/wp-sync-slowtwitch/utilities" "net/url" ) type CategoryData struct { Id int `json:"id"` ParentId int `json:"parent_id"` Name string `json:"name"` ParentName string `json:"parent_name"` } func GetCategory(name, baseUrl, user, pass string) (CategoryData, bool) { endpoint := baseUrl + "wp/v2/categories?search=" + url.QueryEscape(name) response := utilities.GetHttpRequestToWordpress(endpoint, user, pass) var categoryData []CategoryData err := json.Unmarshal(response, &categoryData) utilities.CheckError(err) for _, category := range categoryData { if category.Name == name { return category, true } } return CategoryData{}, false }