[wp-hackers] how to interface plugin with the loop?

TheVitalNet Support support at thevital.net
Wed May 3 10:38:04 GMT 2006


Sorry Mark I didn't see the last part of your reply. 
I'm not really looking at replacing the existing search as I will use my
search to produce results from an additional database table. I've had a look
at the filters and hooks and using them makes sense.
What I haven't worked out yet is how I get my own search function to
actually interface with the main query? Since I'm not modifying the existing
search my own search would have to trigger the same actions as the original
search, so that the filters can be applied to these actions.
What I'm trying to say is, how do I get Wordpress to execute my own search
query and then perform basically like the original query (i.e. take the
results and loop them into a template file, when a user calls my search
function?

Thank you for your help.

Steve

-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com
[mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Mark Jaquith
Sent: Tuesday, 2 May 2006 11:49 PM
To: wp-hackers at lists.automattic.com
Subject: Re: [wp-hackers] how to interface plugin with the loop?

On May 2, 2006, at 8:19 AM, TheVitalNet Support wrote:

> I can't figure out how I would make the results of a search get  
> displayed in
> a template file that uses the loop?

The following hooks interface with the main query:

http://wphooks.flatearth.org/type/sql/

(sorry, none are yet documented, but you can look them up in the  
source to see where they are and what they do... maybe someone who  
has done something similar can chime in with their hook of choice for  
something like this)

Basically, you can just trash the default query and use your own  
query.  Then your query's results will be used in the loop  
automatically.

> I would like to use a template file with have_posts and then loop  
> through
> the results, but I don't know how to call the template file from my  
> plugin

I'd just have it work with search.php ... i.e. set $wp_query- 
 >is_search = true; as you're modifying the query.  No need to make a  
special template file if you're looking to replace WordPress' search  
function.  But, if you did want to use a special template name, you'd  
probably use the template_redirect hook:

http://wphooks.flatearth.org/hooks/template_redirect/

--
Mark Jaquith
http://txfx.net/
_______________________________________________
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