views:

39

answers:

1

What's the correct way of performing an article search from within a Wordpress plugin? I want to perform the search and get a list of matching posts and pages back. That is I want the list back in the plugin code for further processing. I keep thinking there should be a function I can call, but I can't find it.

+1  A: 

I have not worked with this plugin and I'm not entirely sure whether it serves search results in the way you need, but I think it does. Take a look at Wordpress Search API plugin.

Pekka
Thanks. I might resolve to this, but for now I'm still hoping there's some easy way to access the stock search mechanism. That's all I need in my case.
PEZ
Why not take a peek at the search results page in your template? The data is available in PHP form at *some* point before it gets output.
Pekka
Thing is that in the template the search is already performed. I need to find what happens right before that. It's probably going to be really obvious when I find it. =)
PEZ
The search results are probably output in The Loop: http://codex.wordpress.org/The_Loop maybe it gives you some pointers how to get "before" it.
Pekka
Thanks for that link! Finally I got some traction.
PEZ
query_posts('s=' . urlencode($terms[1]) . '
PEZ