[wp-hackers] get_posts with both a custom post_type and custom taxonomy
Aaron Jorbin
aaron.jorbin at gmail.com
Thu Oct 15 21:52:06 UTC 2009
I svn up ed and that didn't solve it so i don't think it was fixed for
2.9. I also looked through the patches and couldn't find anything
related to this. I did open a ticket at
http://core.trac.wordpress.org/ticket/10934 but if it's a dupe, can
someone point me to the original?
On 10/12/09, Peter Westwood <peter.westwood at ftwr.co.uk> wrote:
> If I recall correctly this is already fixed for 2.9
>
> --
> Peter Westwood
> http://peter.westwood.name
>
> On 13 Oct 2009, at 01:58, Mike Schinkel <mikeschinkel at newclarity.net>
> wrote:
>
>> I agree that this is a bug and should be fixed.
>>
>> If a developer sets post_type in $args get_posts() should respect
>> it , not override it.
>>
>> -Mike Schinkel
>> WordPress Custom Plugins
>> http://mikeschinkel.com/custom-wordpress-plugins/
>>
>>
>> On Oct 12, 2009, at 8:52 PM, Christopher O'Connell wrote:
>>
>>> I agree, it should respect post type. Although, I've been solving
>>> this with pure SQL.
>>>
>>> YMMV
>>>
>>> ~ Christopher
>>>
>>> Sent from my iPhone
>>>
>>> On Oct 12, 2009, at 16:27, Leo germani <leogermani at gmail.com> wrote:
>>>
>>>> Hi Aaron,
>>>>
>>>> I often have the same problem when I want a custom query. Thing is
>>>> some
>>>> arguments overwrite the others in this function, and your
>>>> resulting query is
>>>> selecting posts with post type = post.
>>>>
>>>> My workaround is to use the query_posts hook to strip out this
>>>> condition
>>>> from the resulting sql whenever I want.
>>>>
>>>> This is an area where Im not sure wether its a bug or an expected
>>>> behavior.
>>>> But I think if you pass the post_type paramater it should respect
>>>> it no
>>>> matter what other paramaters are passed... Any one agree we could
>>>> open a
>>>> ticket for that? To not let other paramaters overwrite the post_type
>>>> paramater?
>>>>
>>>> Leo,,
>>>>
>>>> On Mon, Oct 12, 2009 at 5:35 PM, Aaron Jorbin <aaron.jorbin at gmail.com
>>>> >wrote:
>>>>
>>>>> 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
>>>>> _______________________________________________
>>>>> wp-hackers mailing list
>>>>> wp-hackers at lists.automattic.com
>>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> leogermani.pirex.com.br
>>>> leogermani.estudiolivre.org
>>>> _______________________________________________
>>>> wp-hackers mailing list
>>>> wp-hackers at lists.automattic.com
>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
--
aaron.jorbin at gmail.com
http://aaron.jorb.in
Twitter: @aaronjorbin
971-231-3499
More information about the wp-hackers
mailing list