The code below can be used to get the post types for a taxonomy in WordPress. This is useful if you know the taxonomy and want to get the post types associated with it. View the code on Gist. To do the opposite of this (get the taxonomies for a post type), see get_object_taxonomies().
In this post, I’ll cover how to replace a post meta query with a taxonomy query. Why, you ask? WordPress’ postmeta database table is not optimized for queries, so querying for posts based on their post meta like the below is inefficient. View the code on Gist. A much more efficient way to do this is […]
In this post, I’ll outline how to create a taxonomy dropdown in WordPress that lets the user choose an option, then reloads the page to only show entries that match the taxonomy term they chose. This is extremely useful for filtering a list of results to show only what your visitor is interesting in seeing. Let’s […]