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
2010-01-13 11:15:04
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
2010-01-13 11:39:35
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
2010-01-13 11:41:10
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
2010-01-13 13:10:18
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
2010-01-13 13:19:49
Thanks for that link! Finally I got some traction.
PEZ
2010-01-13 14:09:04
query_posts('s=' . urlencode($terms[1]) . '
PEZ
2010-01-14 23:41:42