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

Mark Jaquith mark.wordpress at txfx.net
Tue May 2 13:49:16 GMT 2006


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/


More information about the wp-hackers mailing list