Search for Images

Many many people requested a search function for NextGEN Gallery. Although a couple of plugins like Search Unleashed crawl already the content of a gallery, the best solution would a list of images as search result. Why is this such a problem for me and not already includes years before ?

The search injection is not that problem, but it needed always a new template or a redirection to a gallery template which maybe doesn’t fit to your theme layout. I never found the best way, but here is one first try. I’ve create a small addon plugin. You just need to activate it, it has no parameter or settings.

Now you must add to your theme the follow function :

This little code return the image search result for the standard search widget from WordPress. Example here :

UPDATE : I’ve a added the search for tags , there are still the issue with the pagination… but Im working on it.
Should be fixed now with Version 0.7.0, you need as well this update until NGG V1.8.0 is released

You can download the code and a modified search.php for the default theme here :

Download NextGEN Search Engine 0.7.0
Test version @ Google Code

Tagged , ,

111 thoughts on “Search for Images

  1. Bjorn says:

    Great work Alex! I just tried it and it works perfect 🙂

  2. Bjorn says:

    after some extra tests i found out that when a search result has the same name as one of your pages, the navigation no longer works.

    In stead of going to page 2 of the search results, it triest to go to page 2 of the page with the same name as the search result.

    Search result –
    But when trying to enter page 2, it links to

  3. Katn says:

    Love it! Thank you so much! The result is clean and professional looking, just what I needed 🙂 I think it’s making a thumbnail for file names though. Just a gray thumb with the file name on it. Is there a way I can get it to just search the tags? Not a big deal. Thank you sooooo much again!!

  4. I agree to Bjorn. NGG navigation is using a wrong link base:газон

    But anyway that is great feature!

  5. Bjorn says:

    Is it for now possible to get all results on 1 page?
    Would be a nice solution for me until pagination is fixed 🙂

  6. Valerie says:

    Really great job Alex! It was needed!!!

    Thank you!

  7. Reinier says:

    I’m so glad you took the trouble of writing this plug-in.

    I’m a newbee and have been searching the WWW for this function, not believing that someone had not come up with a solution for finding your photo’s by their name / description. And YES ! someone did!

    Works lovely apart from the pagination / navigation. It wont be long ’till this is tackled, I hope.

    Many thanks so far


  8. Reinier says:

    @ Bjorn:

    a workaround for the navigation issue would be tot switch off pagination.
    In admin-bar Gallery –> options –> gallery –> Number of images per page: <>

    Alle pictures will come on one page. No navigation available now.


  9. Eduardo says:

    Hi, thanks for the help.
    Sorry but I am a complete ignorante about PHP. When you said to put some code to our theme, where exactly should we do it, in which file?
    And at the downloaded folder, there are two search files: where to put then? I use Chic Theme… Any help, please? Thank you.

  10. Matthias says:

    how do i activate the plugin?

    i do not get any possibility in my admin area!

    so where or how to activate?

    thank you!

  11. Reinier says:

    @ matthias:

    (though I’m realy not the expert here)

    first you must have installed the plugin “NextGEN Gallery” and have activated it.
    Then you copy the php-script as mentioned (see top of post) by Alex Rabe:

    . . . . and paste it into your theme’s search.php (or search_result.php or something like that, depending on the theme you are using).

    You can edit the search.php from your admin-bar, choose appearence –> edit –> look up the search.php in your right hand-side sidebar.

    left-click will open the php.file.

    For me, the best place to insert the script was right above the part that says:

    After insertion save the php-file and you’re ready to roll.

  12. Valerie says:

    This is strange…
    Is it supposed to search in gallery tags? Because it does not for me… So what are the Nextgen tags for exactly?

    But when I search a specific tag it gives me 1 result while it should give me 2, and no result for all the other tags…

    Help please!

  13. Valerie says:

    OK, the 2nd paragraph of my previous message is not true anymore this morning…. None of the tags seem to be searched?

    Anyone can tell me how Nextgen tags can be used?

    thank you!

  14. Ulrik says:

    Great, thanks Alex…!

  15. Valerie says:

    Wow you are great! Thank you so much alex!!! 🙂

  16. Valerie says:

    Oh alex! A last question. Would it be simple to put a link on a page showing the results of a search?

    If for example I have mny types of dresses in my gallery, could I have a link on a page saying “blue” and then when we click on it it shows all the results of the search for blue?


  17. hartlijn says:

    quite nice this plugin!
    works like a charm.

    One question: how can I avoid one picture to be shown twice, because the search entry word is found in tag and title or description?

    I see you built a duplicate-result check or how to call it: if the search entry is found in both the title and the description, you only show that picture once. Very good.

    But when the search entry is found in the title or description AND as tag for one picture, the picture is shown twice.

    How can I avoid that?

  18. NeilP says:

    Being new to both WP and PHP I’m really very impressed with NextGen gallery and associated plugins. Until a few weeks ago I was using static html.
    I’d love to use this images search but I don’t know what I’m doing wrong.

    Whilst using the default WP theme I’ve replaced the default search.php file with the updated search.php provided in the download. But nothing new happens when I search (posts are returned as standard but no images).

    What do I do with the nggsearch.php file provided in the download? I’m no doubt missing something vital.

  19. Valerie says:

    Hello NeilP, maybe if you use tags only to add information that you do not find in the title it could do the trick…

    In my case, tags add info not provided by the title nor the description and it works very well.

  20. Valerie says:

    Oops sorry, my previous message was for hartlijn. 🙂

  21. peter says:

    Hi Alex,
    Great you’re working on a search function for nextgen!
    The search function you created works well in many situations. In other situations, however, it lacks the functionality i think is needed.
    Currently, not all gallery / album fields are taken into account when searching. Likely the function can be extended to cater for this.
    Another issue i have, is that i use images as illustrations on posts and pages – next to a ‘normal’ gallery. what i really need, is a link to the post(s) / page(s) where the images are used, if they meet the search criteria.

    All in all i’ll continue to use nextgen in combination with search unleashed (su) and qtranslate(qt) to cater for full, multilingual search functionality.
    Maybe the scope of such a search function is a bit too wide for this moment, but i’ll just have a go.. Possibly it makes you wanna have another go at hooking up nextgen and su again!

    Here’s what i have done (in wp2.8.4 with the latest versions of these plugins at that time) to create full, multilingual search.

    i’ve slightly hacked nextgen’s function ‘load_dependencies’ to load the proper backend libraries when su is running to do its indexing. ideally this would be an option in nextgen.
    What is still lacking is a function to kick off su re-indexing when something has changed in nextgen; currently one needs to kick off the su re-indexing manually (or run a cron job or something similar) before the changes in nextgen can be found when searching.

    there’s also a hack i have to apply to nextgen to support multiple languages; function ‘nggloader’ directly loads the nextgen language file whereas that should actually be done with an add_action to ‘init’ so that the loading of the language file is controlled by wp. without this change, nextgen doesnt properly respond to language changes.

    less relevant to nextgen but for completeness sake: lastly there’s a couple of hacks needed in su to a) index all data in stead of only the data of the active language, and b) properly index tags since their translations are stored in a qt specific internal table and not in the wp term tables.

    I’m very much interested in getting this solution properly implemented in nextgen and su and would gladly try to help you do so! so if you would consider giving it another go..?

    Kind regards,

  22. Bolser says:

    in archive, in file search.php dublicated ngg_images_results function. Thanks!

  23. Bolser says:

    or not? My search resault are working without “elseif”

  24. Laura says:

    Help! I’ve downloaded the latest version of the plugin but it doesn’t appear to want to search my NextGen image tags it only searches the pages. Any suggestions?

  25. Laura says:

    Oops – got this sorted now! Wonderful plugin – thanks!

  26. daniellench says:

    can someone confirm if google can search these tags and or descriptions?

    either by default or with the search plugin.

    i am moving this site: from a drupal and gallery2 setup to wordpress and nextgen. the gallery2 has a “keywords” section for images that is searchable and does appear in google et al

    any info would be helpful, thanks for a super plugin. as far as i’m concerned it is the only gallery for wordpress.


  27. Matt says:

    I must be clueless. I uploaded the .zip folder, activated it, and dropped…

    …into search.php and functions.php (not at the same time) and I’m still not getting any results, as well as having two search fields.

    What am I missing here?

  28. Jon says:

    I’m confused about what this add-on plug-in is actually supposed to do? Was this already added into NGG 1.5 and that’s why I’m not seeing any new search functionality? or is there more to enabling it than dropping it in the plug-in directory and activating it?

    Regardless, all I was looking for was the ability to search through the NGG images in the “Add Image” dialog box accessed from the edit post window like can be done for images in the WP Media Library. NGG has the ability to search within the Gallery / Manage Gallery page, but not from the insert/add image box.

    Finally THANK YOU for adding WP thumbnail support to that dialog.

    In truth I don’t think I need most of the functions of NGG, I just want #1 some way to group my 400 stock images into categories and #2 any easy way to find (search and categories) them and attach them to posts in the future.

  29. Kasper says:

    Great plugin. It works perfect when I use an effect like thickbox. But if I want to use the imagebrowser to open the images I can’t click the thumbnails when I search. Any idea how to fix this?

    You can see an example of the problem on this page:

  30. Foto Andy says:

    Thank you Alex for sorting out this otherwise baffling challenge.

    (Tried some of the WP support-generated hacks, they all broke my admin except yours.)

    You continue to earn my donation renewals…

  31. Janet Taylor says:

    Wow, Alex. This is so close to being awesome. If you have time to sort out the pagination and the duplicate results, that would be amazing. Right now, I’ve deleted a bit of nggsearch.php, so that it only searches on tags, which gets rid of the duplicates, but it would be great to get the merging/filtering fully working.

  32. RRG says:

    Hey Alex, maybe in the future you can make a note for us none php experts that what we actually need to do. All of the above is a bit on the confusing side. I think saying, “paste this into your search.php file in place of what is there” would be much better than just “You can download the code and a modified search.php for the default theme here :” I’d guess that many will download and simply upload like a plug in.

    No matter, it is pretty awesome and I thank you. So far it works, but not well. Its listing them in a very small column. I have no idea how to change how this will list out, but if I know you, I have to scour the code to find out.

    My question is…What do we do with the “nggSearch.php” ?? Again, Have no idea as there are no directions for this stuff.

    Thanks for reading

  33. RRG says:

    Sorted it out after trying to just install it as a plug in, Who knew?

    As well, i’m sure everyone is having the same problem, but you have to adjust your CSS to match what is refereed to in the template by Alex. Changes are there is not entry for what Alex called:
    div id=”content” class=”narrowcolumn” role=”main” I made my own css entry and gave them new names so it would renter the columns correctly, rather than overlapping.

    But I do have a real question here..

    With out going into too much detail; how to you tell this wonderful search option to only search for tags, and not the title, description and file name too? I’m sure I’m not the only one who spans multiple images into multiple gallery’s. This is especially true when you use Nextgen with a shopping cart tool to display products.

    Thanks for reading, if you have an idea please leave a note!

  34. RRG says:

    Thanks to Janet Taylor, the answer to my above question about tags only search is this:

    $this->search_result = array_merge( (array) $nggdb->search_for_images( $wp->query_vars[‘s’] ), (array) nggTags::find_images_for_tags( $wp->query_vars[‘s’] , ‘ASC’ ));

    (array) $nggdb->search_for_images( $wp->query_vars[‘s’] ),

    so that the final line reads:
    $this->search_result = array_merge( (array) nggTags::find_images_for_tags( $wp->query_vars[‘s’] , ‘ASC’ ));

    I hope this can help, thanks again Janet!

  35. RRG says:

    Hello, I do have a question.

    This search options works great. You can make it search for tags, you do a search, the images in the gallery populate presto! But the question is, how to you make them populate with their description? The alt tag works, why not the description?

    I’ve been poking around and think it must be in the search.php file of the present theme. Someplace under

    I’d guess that some php code of sorts needs to tell it what to show.

    We all know I’m no good at php, has anyone sorted this question out?

    Thanks for reading

  36. CSM says:


    Nice addition to NGG! Thanks!

    I have a question: Does anyone know how I get this search function to search my custom fields but NOT the words in the description fields?

    I use the ngg custom fields plugin to display artist name, price, region etc but want to add at least region and artist name to the search function.

    Heres the site:

    If you type in a painting name (eg, moonlight), it comes up just fine. But does not pick up any regions, artist names etc.

    Heres a download link to my slightly customized search.php:

    Any ideas?

    Thanks in advance!!

  37. Meginoz says:

    Hello, this sounds exactly like what I’m looking for, but I can’t get it to work. Lots of people have asked exactly what to do with the files in the download and I don’t see an answer. (To those people who posted the same question, then posted “don’t worry I sorted it out” – please tell us HOW you sorted it out.)

    I have changed my theme temporarily to the default one so I can get it working with that and then worry about making it work in my own theme. I replaced the default theme’s search.php file with the one from the download.

    I wasn’t sure what to do with the nggsearch.php file – I put it in the nextgen-gallery folder. Where is it meant to go?

    The search still seems to be just searching blog posts, not image tags, as it doesn’t find anything.

    Can we please have a step by step of what exactly to do with the files?

  38. CSM says:

    Meginoz…I figured it out by good luck rather than by good management!

    I’m no expert so prob can’t give specific advice but here’s how to get the plugin working.

    Go to your dashboard–>plugins–>add new–>upload–>choose file (the zip file)–>install now–> then activate once it has uploaded and installed.

    Then the plugin should appear in your plugins list.

    Once the plugin works, you should just be able to replace your theme’s search.php with the one from the download. this should enable the search function but will likely screw up the whole look of your search page because, as RRG said above, you need to customize the [New] search.php that comes with the plugin to suit your own theme. I.e, you will need to match up the css and div tags to match your theme’s search.php

    What I did was actually take the [NGG] search.php and copy and paste the important code into my theme’s search.php.

    The code I copied starts with the following, and is from line 37 to line 56 (in my editor):

    And I inserted it into my theme’s search.php within the div tags i wanted. I am still yet to finish tidying up the css but you get the idea…

    As you can see I did not copy the code before line 37 because I only want my search to find images, not related posts, pages etc.

    If you want your search results to show general posts and pages etc and then list images you will need to amend the whole file to suit your theme.

    I hope this helps a little! If you want some more info I’ll try to help as much as I can!

    You can see my search working (almost the way I want it) here:

    If anyone knows how to get the search to find the custom fields please tell me!!

  39. CSM says:

    Sorry here is the first few lines of the code I copied…line 37-56

    Image Search Results

  40. Meginoz says:

    CSM, thank you. The code snippets in your post seem to have been stripped out, but I get the general idea.

    It didn’t occur to me to install it by uploading the zip file, as I never install plugins that way, I just FTP the plugin folder up – but as this one didn’t have a folder with the plugin name inside the zip file, I thought you just had to copy those couple of files in somewhere.

    So, looks like basically the steps to get it working are:
    – Install it by uploading the actual zip file through the Add New section on the plugins page
    – Activate it
    – Put the search.php file into your theme

    (Then you have to tidy up the CSS etc, but the above two steps make the basic functionality work.)

    I now have it kind of working, but it is duplicating a lot of the images. I think that might be the problem that RRG posted above, so I will need to have a look at that later.

    Thanks for your help.

  41. Michael says:

    I recently installed this to my gallery and find it has the oddest results. The result of a search gives the relevant images but the images don’t link to their pages…. or, rather, they do but the page is always some random text page or blog post. For example:

    The search
    results in four images.However, they all show the content of the page “Events” when clicked on even tho their URL is the correct picture/gallery page.

    This happens with all images searched. They always show seemingly random content from somewhere else. Can anyone tell me why this might be?

  42. CSM says:

    yeah, sorry…seems the code didn’t want to paste properly…

    I think part of the duplicate results problem is that the search function searches all description, tags and titles. It seems RRG has posted a solution above whereby you set the search engine to just search image tags. maybe that will help?

    Michael could it be to do with your permalinks? Did you activate permalinks in the NGG options? If so, try updating them once and see if that makes any difference…Great artwork too!

  43. Michael says:

    CSM – after clearing the cache and updating (unchecking/save/check/save) the permalinks nothing changed…. It’s very odd behavior but it seems that no one else has this problem.

  44. CSM says:

    I believe to properly update your permalinks you need to go to dashboard–>settings–>permalinks–>then click save changes…you should then get a little yellow box up top saying permalink structure updated.

    By the way have you backed up your blog? I would strongly suggest doing this before playing with code or anything else..I have learnt this the hard way!!

  45. Michael says:

    Well, yes, I did that too.

    The URL that is returned for any given image is something like:

    so that it adds this other stuff in, for whatever reason. It’s different for each search result but gives the same link with a dif. picture number for each search.

    What I really would like if for it to return a link to that particular images page as one would see it from its respective gallery. I don’t use any of the effects and rely on the image browser function.

    By the way – i did back all of this up…

  46. CSM says:

    mmm…Sorry Michael, I wouldn’t have any further ideas…Wish i could help further.

    I am still struggling with the search a little myself…

    If I find anything else out I’ll post it here.

    Good luck!

  47. Meginoz says:

    I am sooo close to having this working. I have it searching, and displaying the images only once now, and it works perfectly with the effects enabled on the gallery. BUT I just want to use the Image Browser, not the effects so it is possible to link to a single image – but when I set it up that way, I can’t get it to open up the large picture when clicking on a thumbnail in the search results.

    The page is here:
    If you click on the thumbnails in the full gallery you will see how it should work. But do a search on “art unit” and you will get four pictures, but if you click on one, it doesn’t open up the image browser.

    I’ve been looking at the gallery.php file to see if there’s something in there that I should put in my search.php file to open the image browser, but I can’t work it out at all. Any ideas?


  48. Meginoz says:

    I’ve just read through the other comments again and noticed that a few other people have had the same problem of it not opening up the large image when using the image browser. Any chance of a fix on that Alex? I’ve been trying to figure out what bit of code controls that in the main plugin, but my PHP skills aren’t good enough.

  49. Jessica says:

    I as well have been searching for this for the site I’ve just finished ( am so glad to find it exists. Here’s my problem. This site uses a theme called Photocrati which does not come with a search.php at all. I installed the plugin and uploaded nggSearch.php to my theme folders, but now I’m stuck. I think I will have to have a page called SEARCH but how do I get that page to pull the search function in? I tried adapting the search code from my own blog and inserting it into my test search page on this site:

    but that didn’t do anything – I had a blank page called search.

    So, can anyone tell me how to call the search function?

  50. Rouven says:

    Hey Alex,

    do you have any news to the pagination issue?

    greetings from Hamburg

  51. Cerafil says:

    I am using Atahualpha theme and I only have a “searchform”

    and no matter where I post this.

    it doesnt work

  52. Narv says:

    I made a little improvement to your search-plugin by filtering out duplicate hits. Those duplicates can occure if the keywords from the search are e.g. in the title as well as in the tags.

    In nggSearch.php (located at wp-content/plugins/nggSearch-v0.6.0) I put in:
    if ( !empty($this->search_result) ) {
    $this->found_images = true;
    $temp_sort = array();
    foreach ( $this->search_result as $key => $value ) {
    if ( in_array( $value->pid, $temp_sort ) )
    unset( $this->search_result[$key] );
    $temp_sort[] = $value->pid;

    This goes instead:
    if ( !empty($this->search_result) )
    $this->found_images = true;

    Probably not the most elegante way of doing the job – but a working one.

    In atahualpa there is an easy way to make this fly – but it took me a while to understand.

    In “wp-content/themes/atahualpa351/index.php” make sure you do NOT have a line looking like this:

    If you have it: Remove it.

    I am not sure, but it looks like it got automatically adding there by activating the search plugin – anyway – not a good place for this code.

    Instead go to the Admin-page – “Design” – “Atahualpa Theme Options” – “Style and edit CENTER COLUMN” – “Content BELOW the LOOP” – at the very end enter:

    Et voila – you get pictures – but ONLY if the keyword is also found in an article – otherwise you get “Not Found”.

    In order to fix this we need to manually edit another file:
    “wp-content/themes/atahualpa351/index.php” –

    locate the line:
    “if ( have_posts() ) : $bfa_ata[‘postcount’] == 0; /* Postcount needed for option “XX first posts full posts, rest excerpts” */?>”

    and replace by:
    “if ( have_posts() or ( function_exists( ‘have_images’ ) && have_images() ) ) : $bfa_ata[‘postcount’] == 0; /* Postcount needed for option “XX first posts full posts, rest excerpts” */ ?>”

  53. Narv says:

    Sorry guys – above the line to remove in Atahualpa was skipped because it contained PHP tags – look out for:
    “if ( function_exists( ‘ngg_images_results’ ) ) ngg_images_results(); ?>”

  54. Narv says:

    and another sorry – the block which goes at the end of “BELOW the LOOP” is this:

    “if ( is_search() && ( function_exists( ‘have_images’ ) && have_images() ) && function_exists( ‘ngg_images_results’ ) )

    Make sure to remove the Hyphens and to wrap it in PHP tags.

    Alex – maybe you can clean those three comments up and put it into one – sorry.

  55. Laura says:

    Hi All

    Brilliant search engine! Having a slight problem on this:

    Originally when I was doing a search on the images, I was getting duplicates – i.e. if the search term was in the title or the tags then it was coming up twice.

    I managed to fix this as per the above. However when I have an image and it has two or more tags:

    Image 1 tag1, tag2, tag3
    Image 2 tag1, tag4, tag5

    When I do a search for tag 1:
    Image 1 and Image 2 appear in my search results

    When I do a filtered search for tag 1, tag 2:
    Image 1 and Image 2 appear in my search results – I should only have Image 1 in my search results as this is the only one that contains tag1 and tag2!

    Any ideas on how to fix this?

  56. Sander Poppe says:

    I currently use NextGen as image library. Great plugin! Resin works well ikke. But what I try or test a search I do not get working …. Can not wait for a properly functioning search function in any Nexgten next update!

    Might result on a separate page to show that you have to create yourself with some sort of widget-like link?

    Gr, Sander

  57. Terry says:

    I have the gallery up and working perfectly on a large collection (8000+ images) of genealogy photos. I am having the same problem as a few others with the pagination being broken on the search results page.

    Has there been a patch or fix for this issue yet?
    It is the only thing stopping me from publishing the site.


  58. Jordan says:

    Thank you Alex and all of you here.
    This plugin works very well on my site.
    I just have one obscure issue.
    The search on tags works for all my tags but for one tag, it doesn’t work.

    I tagged many pics with my son’s name – Adrien. All I get are the pics with his name in the filename. If I remove the filename search as described above, then I get no picture result. Searching on other tag names such as mine (Jordan) work perfectly.

    Can you tell me what’s wrong?


  59. Thank you! I *almost* have this working. I run a site for a granite company and we have a TON of images. I was terribly dismayed when I realized they weren’t searchable!

    If I can figure out the kinks, I’ll post what I did. It’s be a few days!

  60. Kim says:

    I’ve been searching for this exact type of plugin for a long time. I have uploaded it and activated it, but I cannot get it to work.

    My theme does not have a search.php, so I added the nggsearch.php as well as renamed it to search.php and still, nothing works. There is no widget for the ngg search and there is nothing in my admin panel to edit the options.

    How do I get this to work? Any help is greatly appreciated!!
    Thank you!

  61. Well folks, I got it working, broke it, fixed it broke it.

    Bottom line:

    1. I use a the Metro Theme from and WP 3.0
    2. I downloaded and installed the plug-in.
    3. Added the single line to my search.php that Alex put in his original comments at the very top of this thread. (not posting in-line here because I don’t know how to keep the commenting software from stripping out the php)
    4. Edited the nggSearch-v0.6.0/nggSearch.php file and removed the snippets from RRG/Janet Taylor so that this ONLY searches on tags:

    (re-pasting from above):

    Thanks to Janet Taylor, the answer to my above question about tags only search is this:

    $this->search_result = array_merge( (array) $nggdb->search_for_images( $wp->query_vars[‘s’] ), (array) nggTags::find_images_for_tags( $wp->query_vars[‘s’] , ‘ASC’ ));

    (array) $nggdb->search_for_images( $wp->query_vars[‘s’] ),

    so that the final line reads:
    $this->search_result = array_merge( (array) nggTags::find_images_for_tags( $wp->query_vars[‘s’] , ‘ASC’ ));

    I hope this can help, thanks again Janet!

    5. Now I feel like I have some control! If I am careful about tags, my users will get what I want them to get. I can be flowery in my descriptions and not end up with a ton of “hits” for images that aren’t what I want certain search terms to show.

    YEE HAW!!!!!

    Thank you to everyone for your persistence and contributions. Y’all make the world go round!


    (and if a 42 year old real estate agent and mother of 5 can figure this out, so can YOU!!!!)

  62. Kim says:

    Okay, I finally got it working.
    I downloaded the plugin, unzipped it and uploaded it via FTP.
    Then I took the search.php file located in the download (under themes->default) into my theme’s folder. That’s all I had to do to get it working properly. I made sure my tags and file name/attribute didn’t have duplicate content, so the results only show once. So, basically perfect.

    The only thing I cannot figure out is how to edit my CSS to make the search results look better. Right now they are making my right hand sidebar all out oh whack. Anyone have any ideas?

    thank you!!

  63. Z says:

    hi alex.
    i want to say thanks and ask if it’s possible for the search to find only the exact expression ? now it is looking in all over the pics names….

    for example…. if i give one pic the name “888” and i have another pic with the name “138461888” the search will show me the 2 images… i want it to find only “888”….

    maybe you can help ?


  64. Z says:

    hi frieds, i have found the fix for my problem…

    in the file “nggSearch.php” on line 46 you can find the expretion:

    search_for_images( $wp->query_vars[‘s’] )

    just chanmge it to :
    search_for_images( $wp->query_vars )

    and that is it !

  65. Terry says:


    Has there been any progress made on the search results pagination issue? If this issue could be fixed soon, I would be happy to make a donation for your time and my use of this plugin.

    If you have posts displayed on the same page as your image results from Search.php) it adds the link from the last item in the posts results to the page navigation links for image navigation. Hope that makes sense. I’m also hoping to work on this problem with my programmer friend tomorrow. If we can figure anything out, I will post results for everyone.


  66. Terry says:

    Thanks for getting back with me Alex.

    It’s been an issue since January 2010, so I’m sure you have heard plenty of complaints. Do you have any suggestions as to what would even be causing that problem? Anywhere you can point me to look first (in the code)?

    Thanks again

  67. Terry says:

    Remove beginning and ending quotation marks and wrap with php tag

  68. Terry says:

    The Previous and Next arrow code is being converted to it’s symbol.
    You can find this in your original code. It isn’t changed.

  69. alex.rabe says:


    thanks for all the work, at the best send it to me by mail or as file at the issue tracker :

  70. Terry says:

    Couldn’t find your email address.

    You can download the file here:

    and I drafted the necessary changes at your google code project page.

  71. Terry says:

    Just found a mistake in the code I sent you.

    The navigation is fixed for search results navigation, but is broken when you try to navigate straight from a gallery page.

    I will work on it tomorrow and try to come up with a fix.

  72. says:

    thanxs a lot!

    exactly what I needed. Works perfect, except the noted exceptions.

  73. Scott V says:

    I am trying to get the search by tags feature working on the site url shown above. This site is using the gallery to display oriental rugs of different sizes. Here is an example if what a tag may look like 10’x15′, or 12’6″x15′ the returns
    The visitor can set the length and width in feet ‘ on the search

    The returns I am getting back always ignore the first setting and are only showing me the second dimension in the tag

    In this example that is 15’ is there someway for this to read both dimensions for the search and return that information.
    I think there probably is a way to do this I’m just not smart enough to know how to do it.

    Many thanks in advance to anyone that can point me in the right direction on how to do this

    Scott V

  74. andrea says:

    thanks for the plug in!!

    ùworks in wordpress 3.0?

  75. Bruce says:


    I really really want to use this code but I am not at all good with php or any of this stuff. Is there a plain language summary that can explain to me what to do and what the best code is please? I have just been through numerous other groups and some have answers to this problem and none of them work – I just don’t have the ability to troubleshoot the problems!

    I need a simple explaination – here is the code, here is where you put it!!! As if you are explaining to a child!!!

    cheers, Bruce

  76. Bryan Pumper says:

    Whoa! It works man! Brilliant search script / plugin that delivers! If you’re looking for a NextGen search function that works – Image search results that is, this is the one you’re looking for! Great job Alex!

  77. Steve says:

    I have the image search working, but I need to limit the search to a few specific galleries. Is there a way to do this? I want to exclude some galleries from the search.

  78. john says:


    Thank you for a great add-on. I would like to combine this WP Simple Paypal Shopping cart ( I got problem showing the “add to cart” button in the result page. It still in short code, eg. [ wp_cart:120:price:69:end ]; it should becomes “add to cart” button. Need help please

    Thanks before

  79. Max says:


    thank you very much for the plugin!
    And it does search the image tags!
    I have installed k2 and it displays the image-search results in the sidebar. Do you have any ideas how i could display the results on a page?

    Best greetings

  80. John says:

    Hey man this is really really really AWESOME!!!!!!!
    It Works!!!!!!!!!!!!!!!!!!
    Thanks Alot!!!!!!!!!!

  81. Dan Bollinger says:

    I put the code (above in 1.) in my theme’s regular search.php file and it works just fine. Because I wanted the images to show up at the top of the search results page before blog and page results, I inserted that text at about line 7 after the code that includes “Here are the posts related to…”

    Very nice. I like it that is uses the WP regular search function in my header.

    To get past the double image result I just made sure no two words are included in both the Image Title and Image Tags. Its a simple fix.

    Here is my website with “Cushy” from WooThemes and NGG and NGG-search installed. I only have a few galleries added so far. To test this, search for ‘cat’, ‘horse’, or ‘kokopelli.’


  82. But here’s a strange thing I just noticed:

    If I search for a keyword that is in both a gallery image title/tag AND is also in a post/page, THEN the image thumbnails are shown in the search result page.

    BUT, if the keyword is NOT in a post/page, THEN NO thumbnails are shown even if the keyword is in the image title/tag.


  83. Steve says:

    4 1/2 months since the author replied. Is there somewhere else we can get answers?

  84. Roger says:

    I have been trying to get the search function to do what I want it to do. The site that I’m working on is a stock photography site, without blog posts. I want the search to return results based on keywords. I have accomplished that. What I’m having issues with is I would like the gallery results returned to the page (which I have also accomplished) but when there are no results, a message about no results and the search box. Currently, It returns the message and search box, whether or not there are results.

    I have to say that what I know about PHP will fit on the head of a pin but here is my code so far. I’m sure this is quite simple, but then, so am I!

    <?php printf( __( 'Search Results for: %s', 'twentyten' ), '' . get_search_query() . '' ); ?>

    Any help would be greatly appreciated! Go Pack Go!

  85. Roger says:

    Nice-it stripped all the code out-nevermind

  86. Jack says:

    It would be nice to have an option what to search: blog and/or galleries. When I’m on one of the gallery pages I only want to see images in my searchresults, not blog posts.

    I’m also curious to what extend this plugin is being maintained/developed. It’s about the only real gallery plugin that’s part of WP and not an external piece of software.

  87. Joanne says:

    Hi I just donated!!!

    I have a custom theme and the search function is not working out of the box.

    Can you suggest how to make it work for a custom theme?

    I added this to functions.php and unzipped NextGenSearch Engine 0.6.0 into /plugins.

    No joy.




  88. Joanne says:


    Possible to turn pagination off? Since it’s not working — it would be nice just to see all the images.

    What to change?


  89. André says:

    Hi guys. Almost everything working fine (tnx Alex) but i’ve a question/problem.
    The search is working but it still appears the warning that nothing was found. why?
    Thank’s in advance

  90. migf1 says:

    This is great, thank you very much for this! Just tested it and it works fine.

    I have a little problem though. I’m using the WordPress Simple Paypal Shopping Cart plugin, with which every picture has a cart trigger code [wpestore:price:25: … :end] inside its description/alt text. By using the provided (by shopping cart guys) ngg template, each image is presented with shopping cart options beneath it.

    Now, when using the ngg search engine all images are displayed fine but in their description/alt text the shopping cart trigger code is displayed in its raw form (not expanded as cart options, etc).

    Is this an output template issue for the ngg_images_results() function or does it have to do with the cart plugin itself? Is there a way to test ngg_images_results() output using different templates? If so, how? I tried to replace $template=” with $template=’custom-template-name’ inside the source code, without success (I’m no coder, but I think I can pick up any suggestions pretty easily).


  91. hi my questions are almost exactly the same as

    @André and @migf1.

    I can find images – using just the tags but the page still displays NOTHING FOUND – when It obviously has.

    also I need the listed found items to have the wp simple shopping cart code and ability to purchase below the images. not just the image – and text once image is clicked.

    also anyone know how to list the tags in a widget – just like post tags ? rather than searching I’d like customers to click on a tag –

    anyone out there help ? anyone there ? hello !

    I’ll pay for Help.


    Stephen McEwan

  92. perren says:

    Hi, I was wondering if anybody has came up with any ideas for migf1’s problem?
    I have the same issue. Using the eStore plugin and when I do a search the code that is displayed under the results and not the “Add to cart” button.
    I was told that the search result of this plugin is not filtering wordpress short code.
    I am not a coder, but if anybody can point me to the right direction I would give a try to fix this.

    Thanks a lot

  93. Ella says:

    I just want to THANK YOU for such an awesome plugin!!

  94. Lee Daniels says:

    Hi all,

    I’ve noticed some frustration with the search plugin and as a result of a thread on the forum as well as several people asking directly, I just wrote an illustrated tutorial for installing and getting the plugin to work. It is on the Code Fixers site at

    It should be easy to follow and remove the frustration and confusion that surrounds this issue.

    I hope that it is useful to anybody struggling with this problem!

    Lee Daniels

  95. Robin Wyatt says:

    Nice work, Alex! I have this on my site now and it works nicely. However, I’m unclear what the search operators are. I discussed this with Lee Daniels on the WP forums (see towards the end of the thread at and between us, we’ve not been able to figure it out. Could you (or anyone else) shed some light on this?

    Thanks again!


  96. Blaine Motsinger says:


    I updated to the latest NGG 1.8.0, and this plugin still doesn’t return the correct link in the search results.

    The search finds the correct pid=#, but the link it returns is not correct.

    the image tag is 2127 with pid=781
    if the search was for 2127
    then the search page address is
    the search result for 2127 is

    Again, it finds the correct pid and even the correct picture, but the link isn’t correct.

    Does anyone have any ideas about this issue? I really wish this worked. I’m at the mercy of this. No other search plugin has worked, at all, with pagination turned on.


  97. Holger Leyrer says:


    i can’t get it to open up the large picture when clicking on a thumbnail in the search results.
    Any idea?

  98. Blaine Motsinger says:

    Note… after digging in (I’m not very well versed at PHP), I think the issue is in the rewrite.php file.

    any ideas… or anyone that has figured this out?

  99. Hello all,

    @Holger Leyrer

    And other users that have this issue:

    Thumbnails link don´t open. I´m also searching for a code fix, any clues by now?

    I´m using Imagebrowser, and (nextgen) permalinks activated. The search is great, and work fully integrated in the theme. Well done! But the thumbs link don´t open.

    Take a look:

    Any solutions by now? I guess all imagebrowser users out there got this problem…



  100. Chip says:

    Does this work with the WPMU? If not, is there a way that I can make it work?

  101. Andy says:

    @Hélio Cristóvão: I have the same problem. The Thumb-Link don’t open the image.
    Additionally the integration in the theme isn’t perfect. The top of right sidebar begin at the bottom of search results an the left sidebar is not visible.
    My theme ist “Dark 3Chemical DE”.
    Any solutions?

  102. Perren, Stephen and migf1,

    Any luck with getting the eStore/SimpleShoppingCart shortcodes to process on the search results page? I don’t know enough about PHP to edit the plugin from scratch, but if someone can give me some “shortcode processing code” I can see about tweaking it a bit. Would love to get this working!


  103. Randy says:

    How do I get this to work with the Twenty Eleven theme?

  104. Vanessa says:

    Thank you, thank you, thank you!!! Just what I needed. Works for me perfectly.

  105. Brad Kelly says:

    Hi Alex/All,

    Is there a way to modify the extension to combine gallery search results with page/post search results? It seems like if there is a page match, the image results don’t show up.

  106. Pixel says:

    Hi and thanks man…great search solution. Just what everyone needed 🙂
    I’m wondering is there any way to make this search find images by using multi-word search, or more than one term in search box?
    Im sure many people need this…

    If I have two images with descriptions: “nextgen” & “gallery”, for example…
    When type: “nextgen”…it brings image OK.
    BUT, if type: “nextgen gallery” it will say NO RESULTS.
    Is there any way to make it bring both, or more?
    Thanks for support.

  107. Pixel says:

    Correction: “… if type: “nextgen gallery” it will say NO RESULTS.”
    In fact, it will not say: NO RESULT, but will bring results template, just will not show any images.

    Hope someone have solution…


  108. Jeff Meadows says:

    Search function working nicely here:

    How can I apply the caption template to the search results?


Comments are closed.

%d bloggers like this: