Help. I think I have been thinking about this too long. How could I accomplish the following:
– I have a custom post type called ebh_locations.
– Within that custom post type I have a custom field to get terms for the taxonomy category
– On a single post (from the taxonomy category) I want to list the relevant posts from the custom post type called ebh_locations on the single post.
So for example if I check off the category term Addiction within my custom post type I would like that custom post type post to show up in any post within the Addiction category.
So a post listed with the Addiction category would have an area that says:
Addiction is treated at the following locations: [get the custom post type posts that have the category term Addiction checked]
HI @aengstrom
This should be possible by appending a tax_query in a WP_Query loop to filter the posts using the assigned terms. The code would look like this:
$args = array(
'post_type' => 'ebh_locations',
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => array('addiction')
),
),
);
$query = new WP_Query( $args );
For more information, have a look at: https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters