Working on a tool outside of WordPress to query the wordpress database by POST_ID and return the Category Name associated. This is for a real estate website, and the Categories are called “mi_neighborhoods” and are referred to by wp_term_taxonomy.taxonomy.
In one of my other queries to get all the Category names I use:
SELECT *
FROM wp_term_relationships
LEFT JOIN wp_term_taxonomy
ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)
LEFT JOIN wp_terms on wp_term_taxonomy.term_taxonomy_id = wp_terms.term_id
WHERE wp_term_taxonomy.taxonomy = 'mi_neighborhoods'
GROUP BY wp_term_taxonomy.term_id
So I have the POST_ID, I need to return the value of the “mi_neighborhoods” for that post.
Can anyone help?
You can try this SQL query for the taxonomy ‘
mi_neighborhoods
‘ and let’s takePOST_ID = 1304
In general you can get it from this function:
EDIT:
Here is a query that gives you
id/name/slug
of all the terms belonging to the ‘mi_neighborhoods
‘ taxonomy:and here is the same for all non-empty terms: