Every "solution" I have found does not work and this is driving me nuts and I know there must be an easy fix for this. I need to query all posts that fall under:
Custom post type: video
I used the plugin "Custom Post Type UI" to create the post type and taxonomy. I need to have 3 separate queries (different slugs) on the same page if that matters. It doesn't need to be paged. I'm using Wordpress v3.0.5.
Right now I am able to query the post type just fine, but for the life of me cannot query the custom taxonomy slugs.
Thanks for the help!
Michael Fields answers:
Ahhh! This problem is indeed a pain in the ____! The problem here is that you are using the word "type" as a taxonomy slug. WordPress does not like this at all. For all I my projects, I have either selected a new term for the taxonomy or I append the taxonomy name to the post_type like "video_type". I know that this is not an ideal solution to your problem, but I have been down this road before and changing the taxonomy's name, slug and/or rewrite value to video_type will get you out of the woods on this. If it is any consolation, you can always use "Type" for the labels.
Ok I changed the taxonomy slug to video_type, now what would the query code be?
Michael Fields comments:
Not sure on exactly what you need to do, but the following code should return an array of post objects for you to work with:
$videos = get_posts( array(
'post_type' => 'video',
'post_status' => 'publish',
'taxonomy' => 'video_type',
'video_type' => 'featurevid',
I couldn't get your code to work but this did. So thanks for the help.
query_posts( array( 'video_type' => 'featurevid', 'showposts' => 1 ) ); ?>
Ivaylo Draganov answers:
Michael is right here - "type" falls into the list of Wordpress reserved terms:
There are a bunch of others as well. And it also seems like [[LINK href="http://www.456bereastreet.com/archive/201012/names_of_wordpress_custom_post_types_must_be_no_longer_than_20_characters/"]]custom post type and taxonomy names are limited to 20 characters[[/LINK]].
As for the query. Something like that:
'post_type' => 'video', // post type
'video_type' => 'featurevid' // taxonomy slug
That worked, thanks!