WordPress contains a function for getting the tags associated with a post (get_the_tags
) but none for retrieving the IDs of all site wide available tags.
The solution to this problem is quite easy if you remember that post tags are nothing else but pre-defined taxonomies and that you can use the function get_terms to retrieve the terms of a taxonomy:
$tag_ids = get_terms( 'post_tag', array('fields' => 'ids', 'get' => 'all') );
Funny enough there is a function for getting all category IDs (get_all_category_ids).
Leave a Reply