[wp-hackers] identifying the current wp_query() instance
wordpress at dd32.id.au
Mon Sep 15 01:50:35 GMT 2008
bbPress passes a 'name' to each BB_Query AFAIK, It allows for plugins to
hook onto "post authors query" or "thread selection query" or "custom API
query", Perhaps something similar could be intrduced into WordPress?
On Mon, 15 Sep 2008 03:01:35 +1000, Malaiac <malaiac at gmail.com> wrote:
> foreach query, and giving the current instance as a parameter of the
> function ?
> that's not a plugin anymore...
> (technically possible but not reproductible)
> 2008/9/14, Alan J Castonguay <alan at verselogic.net>:
>> What about setting your custom filter in the template right before
>> get_posts and removing the filter right afterward?
>> Sent from my iPhone
>> On 14-Sep-08, at 6:10 AM, Malaiac <malaiac at gmail.com> wrote:
>> > I am playing with the 'posts_where' filter, called by
>> > the call is : $where = apply_filters('posts_where', $where);
>> > My function is
>> > In a page, let's say I have :
>> > one regular $wp_query, showing the posts of the homepage
>> > one $last_pages = another WP_Query
>> > one $most_commented_posts = another WP_Query
>> > These three queries will run through the posts_where filter.
>> > How may the my_filter_function know which one it is ?
>> > How could the my_filter_function know if it's a page or post, or stg
>> > other, query ?
>> > What if my_filter_function needs to know the current query vars ?
>> > global $wp_query; print_r($wp_query->query_vars); will
>> work only for
>> > the first one (and wrong for the two others)
>> > global $qv / global $q; won't work since $qv and $q are not declared
>> > I could manually test in the function (if($most_commented_posts)
>> > then() elseif $last_pages then() else (...use $wp_query) )... not very
>> > elegant.
>> > any other ideas ? I'm not an OOP guru, so I may miss something here.
>> > Malaiac
>> > _______________________________________________
>> > 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
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers