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

TheVitalNet Support support at thevital.net
Tue May 2 21:13:56 GMT 2006


Thank you for your reply. And how do I tell Wordpress which template file to
use after the query, if possible without hacking the Wordpress code?

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