How to query Posts from a custom post type which contains a custom taxonomy?

You have one or two issues here and possible future bugs that you might encounter

  • term in your tax_query should be terms

  • Be carefull with terms having dates as names and especially dates as slugs. This can cause issues and unexpected results if custom permalinks clash or if something falls into the template hierarchy for some reason.

  • Never use the name field in a tax_query. There is an issue with the sanitizing of the term name before the join clause is constucted for the SQL query in the WP_Tax_Query class. This is a known bug that will propably be there for many versions to come.

    I have explained the complete issue in this answer I have recently done, so feel free to go read the whole 9 yards. But in short, what basically happens is, WP_Tax_Query uses sanitize_title_for_query to sanitize the input from the name field in a tax_query. This function strips all whitespaces and special characters and also convert all capitals to lowercase. So a term name like My Term Name/2 gets converted to my-term_name2 which will fail as that term name does not exist.

    In short, as precaution, do not use the name field in a tax_query, rather use term_id or slug. If you do not know these values, then use get_term_by() to get the term ID or slug from the name and then pass that to the tax_query

  • You should also make sure that you can query posts from your custom taxonomy and custom post type publically. Make sure that have the correct values set when you register the post type and taxonomy