Get a Post's Tag from Database
-
After trying to figure it out on my own for a few hours, I seem to be going around in circles. Basically, I’m trying to get the tag of a post from the database from a page outside of wordpress. I use wordpress as a CMS for this site and not really a blog. I’m passing the post ID in the url and using that as my starting point.
I figured somewhere in wp_posts it would store the tags of the post but it doesn’t appear as so.
I found in wp_term_relationships, I can search in object_id for the post ID to get the categories and tags of the post. But this doesn’t tell me if the id is a category or tag.
So then I have to search in wp_term_taxonomy to find which of the id’s I just pulled is a tag id (my posts only have 1 tag and 1 category).
Then, once i have the tag id of the post, I can look in wp_terms to get the name of the tag.
That seems like a lot of searching to get the name of a tag associated with a post. Is there something I’m missing or do I have to do all these database queries to get the name of a tag?
- The topic ‘Get a Post's Tag from Database’ is closed to new replies.