[wp-hackers] identifying the current wp_query() instance
Malaiac
malaiac at gmail.com
Sun Sep 14 17:01:35 GMT 2008
foreach query, and giving the current instance as a parameter of the function ?
that's not a plugin anymore...
(technically possible but not reproductible)
M
2008/9/14, Alan J Castonguay <alan at verselogic.net>:
> What about setting your custom filter in the template right before calling
> get_posts and removing the filter right afterward?
>
> Alan
>
> 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
> WP_Query::get_posts()
> > the call is : $where = apply_filters('posts_where', $where);
> > My function is
> add_filter('posts_where','my_filter_function');
> >
> > 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
> global;
> > 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
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list