This page deals with possibilities to enhance the integration of the Advanced Search plugin for WordPress.
Simple Improvements
- All elements of the advanced search form have
idand/orclassattributes, so the form can be completely designed with CSS to best fit into your WordPress theme. - Add the
<?php echo as_form('as'); ?>tag to yoursearch.phpto offer the Advanced Search on an unsuccessful search.
Configuration
All configuration happens in the file settings.php to change any of the settings, you must open this file in a text editor and apply the desired modifications. A short list of options follows; you’ll get the idea.
AS_UNIVERSAL: Set this to'true'(string, not boolean!) in order to let all WordPress searches be performed by Advanced Search.AS_DO_HILITE: This is the master switch for searchterm highlighting.AS_HILITE_ATTR: This is an array where you can specify attributes that are to be applied as highlighting.AS_FORM_*: These are switches to turn elements of the large search form on or off.ASL_FORM_*: These are switches to turn elements of the sidebar search form on or off.
Translations
There are localized versions included with the plugin download in the following languages:
- German, search form and hints popup,
- French, kindly provided by Luc Saint-Elie: search form (translator for hints popup wanted!),
- Spanish, kindly provided by Trebol-A: search form and hints popup,
- Italian, kindly provided by Andrea Barbieri: search form and hints popup,
- Czech, kindly provided by Martin Štěpán: search form and hints popup.
For version 2.0, the existing translations need to be revised (not much). If you’d like to do this, please grab the .pot file from the plugin and translate the new/changed strings. And of course, if you want to contribute a new language, please read the great Codex docuentation on how to accomplish this. When you’re done, please send me the translations.
Background
The plugin uses the fulltext feature of MySQL. When you activate the plugin, it will add FULLTEXT indices to the columns post_title, post_content und comment_content. This is nothing to worry about, and you can (but don’t need to) remove it if you decide to uninstall the plugin. To understand the implications of the MySQL FULLTEXT feature (not only positive ones!), please have a look into the according chapter of the MySQL documentation.
By default, the minimum word length is four letters. If you have access to your MySQL configuration, you can lower that value in order to allow searches for shorter words and TLAs. The MySQL documentation describes how you can modify the minimum word length parameter. Basically, you need to add the setting ft_min_word_len=3 (or lower) to the [mysqld] and the [myisamchk] sections of your MySQL config file. Then you must restart the MySQL server and rebuild the FULLTEXT indices with the following MySQL commands (given your WordPress installation uses the standard table prefixes.):
REPAIR TABLE wp_posts QUICK;
REPAIR TABLE wp_comments QUICK;
Please also note that this will also affect all other databases that are managed by your MySQL server! This means you must repair all tables that use FULLTEXT indices with the above method.
Allowing words shorter than four letters
What else?
Feedback and improvments are as always highly welcome. Please leave a comment below. Have a lot of fun with the Advanced Search plugin!
That’s it! Have a lot of fun with the Advanced Search plugin!
In case you need individual, advanced support: Zirona also provides professional support for this software and its integration on your website (as well as WordPress support in general). Please don’t hesitate to contact us and ask about our services.


J am 25. Oktober 2006 um 03:01 #
great addition to the wordpress arsenal!
question tho… is there a way to exclude specific posts form the search results?
best,
j
Alex Günsche am 25. Oktober 2006 um 11:28 #
Hello J,
Not this is not featured at the moment, although it is technically possible.
But what exactly do you mean: Should it be possible for the administrator to exclude posts via the backend or for a visitor via the frontend?
Todd am 2. November 2006 um 05:26 #
On another site I work with (running WP 2.0.4), I tried adding the PHP call for ‘ctas_form()’ in order to display the advanced search on an unsuccessful search. Nothing displayed. In fact, no matter where I put that ‘ctas_form()’, nothing ever displays. I created a new page and put in “advancedsearch” as directed and that shows up just fine; I know the plugin is working. But I can’t get any of the advanced search form features to display anywhere else on the site. Does anyone know of any plugins this one doesn’t play fair with? That’s the only thing I can think of. Any ideas as to why nothing displays? Any tests I can run to figure out what’s happening. Thanks.
Alex Günsche am 5. November 2006 um 14:32 #
Hi Todd,
my mistake, sorry. When I wrote the documentation, I forgot a little
echobefore the call. Now it’s correct.Sigsol am 28. November 2006 um 21:00 #
Hi Alex,
Like J, I am lloking for a search plugin that can allow the admin to omit pages from the search, in my case the sitemap and search page. You have said that it would be technically possible, are you planning to implement this in a future release? Please!?
Sig
Alex Günsche am 29. November 2006 um 11:45 #
I see. If it’s only about the ability that you (not your visitors) can exclude a page, you can simply do it yourself. Open the file advancedsearch.php and add a new line
' AND post_id != 2 ' .between ll. 429 and 430. Instead of2, insert the ID of a page; for each page you’d like to exclude, add one more of these lines.TheMystical am 3. Dezember 2006 um 20:52 #
The plugin seems great, however I can’t find a way to implement a search field in a sidebar widget, how to use ctas_form() thing is confusing me!
Alex Günsche am 21. Dezember 2006 um 15:07 #
The function
ctas_form()simply aggregates and returns(!) the elements of the search form. By default, it is not widgetable, but there might be ways to accomplish this.Ricky Irvine am 24. Dezember 2006 um 08:11 #
Great plugin! I’m wondering if there is a way to use the plugin to search/show selected categories, as discussed here: http://wordpress.org/support/topic/98239 (without search term)
Alex Günsche am 24. Dezember 2006 um 09:29 #
Hello Ricky,
the plugin does have the ability to filter by categories, but it is by default not designed to work without any search terms.
Nicola am 12. Januar 2007 um 17:37 #
Hi,
I want to create my own search form: by default it should search on all pages, posts and category. How I can? I’d prefere if the search box will be very simple, with a one field.
thank’s
Alex Günsche am 15. Januar 2007 um 03:17 #
Hello Nicola,
You need to create a template page as described above. Instead of creating the normal HTML fields, you must create hidden <input> elements and give them the values they would usually have as checkboxes or radiobuttons.
solemnchaos am 15. Januar 2007 um 08:32 #
Just wanted to say thank you. With a little work I was able to integrate advanced search into my site very nicely.
martin am 17. Januar 2007 um 13:13 #
thx for nice plugin!
please, i try to localize plugin into czech language (with poEdit i prepared first version of ctas-cs_CZ.po and *.mo files, working on hint file now), but i dont know how-to change default eng language to czech …
[firstly i installed plugin (upload via ftp, activation via dashboard), created page, all works fine and correct, after it i put these po+mo into /advancedsearch/l10n/]
im sorry, may be i missed some setings dialog in dashboard of wordpress or setting line in .php file? thx for info M.
Alex Günsche am 18. Januar 2007 um 12:04 #
Hello Martin,
nice to hear you have a translation.
You can set the language of your WordPress to czech by setting the parameter
WPLANGinwp-config.phptocz_CZ.However, you can send me your translations to contact at zirona dot com, I will have a look at them.
martin am 18. Januar 2007 um 13:25 #
hello,
thank you for response, my answer you can find in your mailbox
FaSt3nD am 22. Januar 2007 um 19:41 #
how could I search in content of each post?
Alex Günsche am 23. Januar 2007 um 11:44 #
How about Ctrl+F?
Radiomestiza am 29. Januar 2007 um 03:33 #
up and running!! thank you so much… how can i make th authors NOT listed, just always search em all
thanks!
Radiomestiza am 29. Januar 2007 um 03:36 #
also… i have Jerome’s Keywords plugin (http://vapourtrails.ca/wp-keywords) installed… how can i make advanced search to ALSO use those tags
Boris am 30. Januar 2007 um 00:23 #
hey there alex,
i am having a slight problem with advanced search on my site. i recently added a few categories that are being displayed as a sideblog. none of these categories show up on the advanced search page though. do you have a solution maybe?
i integrated the bbpress forum with wordpress (2.1). there is a bbpress plugin to search in wp posts as well when people search in the forums. would it be possible to do it the other way as well? search bbpress posts when searching with advanced search?
also, are there any plans to include to search for tags (utw for example)?
cheers for this great plugin.
b
Alex Günsche am 30. Januar 2007 um 17:30 #
Radiomestiza, if you create an own template as described above, you can simply omit the function
ctas_form_authors(). This will result in not defining any authors, which again means for the plugin to ignore author criteria. As for UTW, JK and tags in general: I’m not planning to implement a search on tags at the moment, since I’m not using them and it’s a bit tricky to manage them properly with the techniques used in the Advanced Search plugin. However, if anybody has an appropriate piece of code for tags support, I’d regard an inclusion with favour.Boris, as for the sideblog: are the categories in the
categoriestable in the database, or do they have an own one? As for the search: this might be possible, but it would be a lot of hassle to implement it. The Advanced Search uses MySQL’sFULLTEXTfeature, and that’s hard to integrate with a larger number of tables. As for tags: see above.Boris am 2. Februar 2007 um 22:50 #
sorry for the late reply. i just had a look and all the categories are in the wp_categories table. i did some layout modifications to the plugin, but i checked by installing the original files and i still only get the 2 cats displayed.
thanks for your help.
Alex Günsche am 5. Februar 2007 um 21:42 #
Could it be related to plugins? Which ones do in use?
Ezequiel am 22. Februar 2007 um 00:42 #
(comment language: Portuguese brazil)
O plugin é muito bom, mas espero que na próxima versão possibilite acrecsentar na sidebar.
Don am 28. Februar 2007 um 06:16 #
Hi,
It seems that the categories are only listed if at least one post exists with that category assigned.
I also assign categories to pages using the page organizer plugin at
swordfish
It uses the same categories as the posts but for some reason Advanced search doesn’t recognize a category if only assigned to a page.
Can you tell me how to tweak the code? I assume it’s just a matter of changing the SQL to include the field(s) the page organizer added.
Please advise where the SQL code is in your plugin and I’ll tinker with it.
Thanks!
edit by Alex: Inserting your other comment here…
Your code:
if ($ctas_recurse == '0') {$ctas_allcats = $wpdb->get_results("SELECT DISTINCT (category_id) FROM {$wpdb->post2cat}");
if ( count($ctas_allcats)
In this code I also need to query for page2cat_id from page2cat table so the category shows in the category list of the search page if I assign a category only to a page and no posts.
Can you show me what to edit here? Thanks!
Alex Günsche am 28. Februar 2007 um 10:55 #
I don’t know this plugin, but it might help to change the parameter in the call
ctas_form_cats()to display empty categories.Don am 28. Februar 2007 um 14:50 #
Hi,
Thanks that works!
Can I exclude categories from the list as well? How?
Alex Günsche am 28. Februar 2007 um 15:02 #
Have a look at the
$ctas_excludeparameter. When you give it a comma-separated list of category IDs, these should be excluded.Don am 28. Februar 2007 um 16:05 #
Excellent! Thank you!
Is there documentation on all these parameters that I’m missing?
Alex Günsche am 1. März 2007 um 08:34 #
The function
ctas_form_cats()is derived fromlist_cats()from the WP core, and it uses the same parameters. Therefore, the documentation forlist_cats()can be used as reference.Kelly am 3. März 2007 um 14:59 #
I’m having the same problem Boris is. Alex, would this be solved by a UNION? Something like: SELECT DISTINCT id FROM (SELECT id FROM post2cat) UNION (SELECT id FROM page2cat)
I tried it but don’t know enough to get it to work.
Serola am 21. März 2007 um 15:27 #
Hey, it would be useful to have a tag that gives a similar list as list_cats() but it would count also the categories for pages and the links would display the pages on index.php like the Advanced Search form does. So, what is actually needed is something like ctas_form_cats() tag where the check boxes are replaced with links that perform a Advanced Search query on that specific category.
Matt am 16. April 2007 um 23:20 #
Hi, this is a great plugin… Is there anyway to get it to search full-words only? (Or is this supposed to happen anyway; mine isn’t). I can’t see anything in the MySQL documentation, though, so perhaps this is beyond what’s possible??
Alex Günsche am 16. April 2007 um 23:41 #
That’s correct, it searches nothing but full words. Only if you set an asterisk at the end of a term, it is considered as a word’s beginning.
Matt am 18. April 2007 um 00:23 #
Ah, yes, it does, sorry I’m confusing myself by mixing up Advanced Search and normal search results ;/
Matt am 18. April 2007 um 12:15 #
Sorry, me again… I created a custom search form, but left out category options… then the search results came back funny, because they search through ‘uncategorised’ posts, which includes things like images (ie, post attachments)… And the attachments come up higher in relevance than the posts themselves (which isn’t really what I want). So it might be good to change line 421-422 in advancedsearch.php to
if ( empty($ctas_cats) ) {
//$ctas_cats = 'AND ( ( 1 = 1 )'; // no categories requested at all
$ctas_cats = 'AND ( ( post_type != \'attachment\' )';
??
Although a total solution would probably be more complicated than that, since it might be better to get attachment hits to match the parent post instead…?
tim am 18. April 2007 um 12:57 #
Hi, I am trying to get Advanced search to actually list the sub catagories on the search page so the user can choose which ones to search in?
UPDATE: OK I got this list working, albeit not showing the lables, using the child_of function.
I am really trying to allow a user to display posts from selected categories without the need for a search term,, is this possible with a * wildcard or the like?
thanks
Alan am 5. Mai 2007 um 02:26 #
Like Tim How do I make tickboxes unticked by default. That is, the user has to tick any option they want
I have thousands of child categories and users need to search in only one of these child categories therefore the question
alexandre van de sande am 9. Mai 2007 um 21:51 #
Hello. I am trying to translate the plugin to brazilian portuguese but when I open the po file in poeditor I get a blank file. Am i doing something wrong?
Paul am 16. Mai 2007 um 07:22 #
Thanks for the great plugin. I’m in the same boat at Alan at number 39 - I would much prefer the tickboxes to be unticked by default, so that users can easily tick one or two boxes to narrow the search. Is there some way this can be done?
thanks
Steven am 16. Mai 2007 um 13:10 #
Search works great when there are results.
When there are no results found, I get a new page that just shows a simple search box with no options.
What needs to be tweaked so that if there are no results, it would return to the full advanced search page rather than a basic page?
NBoy am 17. Mai 2007 um 03:05 #
You state above:
I also need to exclude certain pages - I can’t see where you mean in the code, could you make this a little clearer (line 429-430 doesn’t seem right).
PLEASE tell me (and numerous other people!) where this is!! I really appreciate all the work that’s gone into this plugin, and if I just had this functionality it would be perfect!
cogmios am 22. Mai 2007 um 00:59 #
including the tag on the default page template gives me a 500 internal server error: http://www.cogmios.nl/advanced-search . Also when using
but obviously not when i just. If anyone has a hint that would be welcome. The php tries to do something that the server does not like. well.. lets walk through the plugin code tomorrow…Jane am 30. Mai 2007 um 21:12 #
Is this compatible with 2.2 and can we so a search without anything in the “search text” area?
Alex Günsche am 30. Mai 2007 um 21:29 #
It is supposed to be compatible with 2.2. And, no, you can’t search without anything in the search field.
Robert Buzink am 19. Juli 2007 um 12:22 #
Would be nice if it replaced default search. In that way searches done from the default form in the sidebar also feature highlighting and faster mysql text-search.
This could be implemented by using the normal s= as search-term GET variable in your script and replace the default search function with yours.
Alex Günsche am 19. Juli 2007 um 12:41 #
Robert, try AdvancedSearch Lite. It does exactly that.
Wadeon am 16. August 2007 um 19:34 #
Hello,
Could you help me to figure out how to make a simple form with input box for use in my sidebar? I have created an Advanced Search page and removed it from my pages list. I have then entered a link to that Advanced Search page in a text sidebar widget. See here in upper right… http://wedreaming.com
What I’m trying to do is to just make a one input box there to enter a search term and then display the results. This would search everything, there is no need for me to exclude any categories or pages.
I would be very grateful if someone could clue me in as how to accomplish this. I’m guessing that I just need to make a form and then somehow reference the Advanced Search functions, but I’m not sure how to do that.
Thanks for any guidance anyone here could provide:)
Wadeone
Alex Günsche am 20. August 2007 um 09:55 #
Try this:
http://www.zirona.com/software/wordpress-advanced-search-lite
Psycentr am 4. Oktober 2007 um 18:49 #
We don’t want the “include results from” field to show up, since our users will only be searching posts, not pages. But when we try to get rid it, it breaks the search and we get no results. Any ideas?
PS> It’s a great plugin!
Katarzyna am 5. Oktober 2007 um 20:04 #
Your advanced search has saved my life! The wordpress search was driving me insane. This one does very well indeed. I will be playing with it a bit because I need to search some meta data. I didn’t check exactly how to do it yet. What is your hunch? Is it doable? Anyway. I just wanted to let you know I translated the thing to Polish. Let me know where to send the files.
best. Kasia
Katarzyna am 8. Oktober 2007 um 18:23 #
I found that when you search comments as well as posts and pages there is too few results (in my case it was less than when I searched posts and pages only). It’s, I believe, because there is INNER JOIN in the sql query instead of LEFT JOIN. As a result only posts and pages with comments are being searched. Correct me if I’m wrong
Still have got the Polish translation
cheers
dalton am 20. November 2007 um 17:16 #
I think this page needs to be updated to work with AS 2.0. I used the function
< ?php echo ctas_form(); ?>as indicated above, but get undefined function error. I changed it to
< ?php echo as_form('as') ?>which seems to work.
Regards,
Dalton
Alex Günsche am 20. November 2007 um 17:23 #
Thanks for the hint … In fact, I had already updated the site, I just neglected to insert the new content into the live page.
Alex am 31. Dezember 2007 um 06:25 #
I’m having some issues with Advanced Search on my site.
I use a number of custom
new WP_Query('category_name=name&showposts=4');style small loops on the sidebar and various places. Whenever I install the search and even use WP’s built-in search, ALL of my custom loops go crazy.Instead of listing just “showposts=4″ it just fills up with the search results and LOTS of text. I’m not sure how to fix this because it seems like a very complicated SQL issue and I’m not sure where to go next.
Any help would be greatly appreciated. Thanks!
vait am 27. Januar 2008 um 14:49 #
hi!
I tested advanced search lite in widget form and everything works absolutely finde… then i copyed my wordpress in anoterh directory and now every search is without result :/
i deactivated the plugin, reactived but nothing happens… still no results. can anyone help me ?
greets
vait am 28. Januar 2008 um 08:16 #
problem solved.
Raven am 2. Februar 2008 um 15:39 #
Hey Alex, thanks for a great olugin. The lines you describe 429 and 430 don’t exist in that PHP file. Can I ask you to be a bit more specific as to where you can exclude pages from the search from the backend?
Take care | Raven
Alex Günsche am 2. Februar 2008 um 15:53 #
Of course, these lines refer to an older version of Advanced Search. Please have a look yourself, I don’t know from mind right now.
Nick Prignano am 25. Februar 2008 um 23:30 #
Is there any way to search other tables in your database with this plugin?
Alex Günsche am 26. Februar 2008 um 00:07 #
Nick, you can use the technique this plugin uses on other tables. The plugin itself and its database queries are only for the WordPress structure. You would have to adapt the code to your specific needs.
Damien am 4. März 2008 um 03:05 #
This is a very nice plugin - thank you.
However, I need to change one thing and don’t know how to do this. I am using v.2.0 with a full page for advanced search and triggering the advanced functions in search.php if no results are found.
I want to change the function as_headitems so the javascript and css are loaded *only* on this page. How do I do this please?
Alex Günsche am 4. März 2008 um 12:12 #
< ?phpif (strpos($_SERVER['REQUEST_URI'], 'your_search') !== false)
{
// whatever
}
?>
DoZ am 4. März 2008 um 21:22 #
For those who wants to uncheck by default the category check boxes, do this:
- open form.php
- remove checked=’checked’ on line 370
- save an upload new file
This works fine for me!
DoZ am 6. März 2008 um 23:28 #
Can somebody tells me how to do this…?
If I search a word in 2 or more categories I see every post tha has that word and belong to one of the checked categories…
I want results only if the post have that word and only if it belongs to ALL the checked categories, so I can reduce the results.
How is it possible?
(many thanks)
Danny am 2. Mai 2008 um 15:26 #
Thanks for the useful plugin. Is it possible, though, to display only excerpts rather than the entire posts?
Amir Ashtiani am 20. Juni 2008 um 08:03 #
Hi admin
Tanks for Good plugin !
I make Persian(farsi) transration !!
please Add plagin package and use this.
download po & mo file :
http://ouo.ir/lang/lang-fa_IR.zip
Leah Masci am 13. August 2008 um 23:44 #
Alex-
Thank you for creating this plug in- it is very useful and two questions:
We want to adjust this plug in to only search posts and to not display the first category and subcategory (Artist and Roc Goudreau).
Can you tell me what page and code needs to be changed?
Thank you very much,
Leah