Does anyone know if search results can be sorted by category, so final output looks something like:
3 results found
Blah blah article
Blah blah news title
Blah blah event
Tried to trick it out, but without much luck so far. Don’t even know if it is possible in the first place.
Do you want these in one long list like regular archives only sectioned?
The way I see it you may have one of two situations to consider.
1. You either have a few hundred posts and at 20 or so per page, you may not really have a situation where there would be multiple categories of posts on one page.(If that makes sense.)
2. The other situation is that you have only a few posts in each category and really only need to show 4-6 posts from each. In which case, they can be separated by category for easy viewing and allow you to title each section accordingly.
In the first case, you might be better off just creating archive pages such as category-articles.php, category-News.php, etc. Just copy your archive template but title the file accordingly. (There are other ways to do this as well.)
In the second case, you can have multiple loops on a page. If you are a coder these tuts may help:
For one long list as a regular Archive you can also use orderby=parent in those query_posts.
Racer x, thanks for your reply…
I only need to be able to show all the posts for a given keyword for category #2 but not for all the categories available at my blog.
Is there a way to have a link like:
Where &cat=2 means that I’m searching for the keyword “Phoenix” only in the category with id 2?
I’d like to hope that there is already a code to append to the search link result page as I’m not absoulutely looking for a search form (just for the link that returns the results for a given keyword for a given category).
Sorry for the long post but I hope I’ve clarified my thought…
You can add category to the search but it does require adding a few additional rules to the rewrite array.
The alternative is to try some of the plugins that extend the search capabilities, avoiding any need to understand how to add to the rewrite array.
It is possible that your theme’s archive.php page has a bunch of php “conditional” statements. This means it detects if the query is an archive by category, archive by month, archive by tags, etc.
If your theme has these conditional checks then you could simply add a tag(the keyword in this case) to the posts that have that keyword in the story.
Then you just create a link to that tag’s archive in this manner:
Provided you have that permalink structure.
Hope that it could have been a little easier…
Racer, the idea of the tag appended to the post doesn’t work for me as all my posts are coming from feeds and check any post to insert the tag would take me days…
I’ve also take a look to the plugin section but, as I supposed, there is not a perfect one to have easily what I (and suppose a lot of editors) need.
WordPress advanced search seems not to play very well in 2.9.2 or at least there’s no way to search within categories.
I’ve tried some of the search plugins available but with absolutely no luck.
I’m starting to think that it’s something not available by default or by plugin.
That’s a real shame as this blog platform would be “more” perfect with it…
If you want something to be modified/customised beyond standard functionality, that leaves you a few options.
1. Find a plugin that does it (if not see 2).
2. Find a plugin that comes close and modify it to suit (if not see 3).
3. Search for information shared by someone who has already done the same (if not see 4).
4. Hire a developer to write the customisations for you.
So, if Search Unleashed comes close, what does it lack that you need, perhaps if you could be specific about what additions or modifications it needs someone may offer to help (they also may not – it’s just a suggestion).
- The topic ‘Sort search results by category’ is closed to new replies.