[wp-hackers] Get query variables and tags

DD32 wordpress at dd32.id.au
Wed Feb 4 00:58:23 GMT 2009


WP_Query DOES accept 'tag'
http://trac.wordpress.org/browser/trunk/wp-includes/query.php#L1178 &
http://trac.wordpress.org/browser/trunk/wp-includes/query.php#L1852

So you might want to recheck you were using the right stuff :)


2009/2/4 Ade Walker <photofantaisie at gmail.com>:
> Thanks DD!
>
> I was hoping to take a shortcut as get_query_var works fine. However,
> WP_Query doesn't seem to accept tag= as a parameter (I was hoping I could
> simply pass the $tag variable to WP_Query). I already have a main loop going
> on in the same page and therefore I don't think I can use query_posts
> either, which would have let me do this. I'll take a closer look at the
> get_objects_in_terms and get_posts suggestions to see how to get this to
> work.
>
> 2009/2/3 DD32 <wordpress at dd32.id.au>
>
>> What i would do:
>>
>> $tag = get_query_var('tag');
>> //Might need to convert 'MyTag' into a TermID here.. not sure
>> $objects = get_objects_in_term('post_tag', $tag)
>> $posts = get_posts( array('post_in' => $objects) );
>>
>> Or something similar.... You'll have to check the get_objects
>> function.. and WP_Query for the correct usage of post_in..
>>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list