Support » How-To and Troubleshooting » If post is ONLY tagged with one tag…
5 years, 12 months ago
Howdy folks, first post!
I’m trying to modify my WP_Query() to filter out any post tagged with ONLY ‘canada’. If it’s tagged with ‘canada’ and something else, ‘canada’ + ‘music’, it can stay.
Any ideas how to determine if a post is ONLY tagged with a single tag?
Use the function get_the_tags() to retrieve an array of the tags for the post. Then, check that the array has only one element and that the element is named ‘canada’.