[wp-hackers] get_posts with both a custom post_type and custom taxonomy

Aaron Jorbin aaron.jorbin at gmail.com
Mon Oct 12 20:35:10 UTC 2009


I'm having an issue with get_posts and using a custom post_type and
custom taxonomy.  It seems to always return empty.  If I do
`
$args = array('post_type' => 'my_post_type', 'foo' => 'bar');
$my_posts = get_posts ($args);
`
foo is registered as a registered taxonomy that has query_var set to true.
If I do a custom query for the following, it returns exactly what I
would expect.

`
$sql = "SELECT * from $wpdb->posts
	LEFT JOIN $wpdb->term_relationships ON
$wpdb->term_relationships.object_id = $wpdb->posts.id
	WHERE `$wpdb->posts`.`post_type` = 'my_post_type'
	AND `$wpdb->term_relationships`.`term_taxonomy_id` = $my_term_id
	";

`

Is there an additional step that I am missing?  I opened up a trac
ticket at http://core.trac.wordpress.org/ticket/10934 but haven't
heard any responses there, so perhaps this isn't an actual bug.  Any
help that you can lead would be greatly appreciated.

-Aaron Jorbin

-- 
aaron.jorbin at gmail.com
http://aaron.jorb.in
Twitter: @aaronjorbin


More information about the wp-hackers mailing list