I have 5 different custom post types and one custom taxonomy. I've been able to get a taxonomy dropdown using
<?php wp_dropdown_categories( $args ); ?> but I noticed that I was not able to restrict the taxonomy dropdown to show the terms which have posts from a particular post type.
Some of the comments that I got asked me to create a different taxonomy for each post type but that is not possible in my case since my custom taxonomy is for defining a location and I'd like all the 5 custom post types to use this one taxonomy.
I know that I can load the posts from a post type and get the terms from those posts and use a
foreach loop to loop through these and output them as options in a select field but I don't want to use this since I would lose the hierarchy that I had set up for the taxonomy. If I can get the hierarchy using this method then I'm open to that too.
Is this possible or do I have to create separate taxonomies for each post type?
UPDATE I wanted to be able to add a custom field value also as a parameter. TheDeadMedic's answer does that.