I've found the following instructions to activate searching of tagged images in NextGEN-Gallery but I can't find the PHP file they refer to:
1) Add this code in your file search.php (inside your template folder), right after <h2 class="pagetitle">Search Results</h2> or somewhere (depending your template) after <?php if (have_posts()) : ?>, otherwise it wouldn’t find the pictures.
Pay a special attention to the line $nggpictures = ngg_get_search_pictures($keywords, '');
since on the second function argument ( ” ) you may indicate the number of pictures you want to display on each row result. IE, if you want to get 6 pictures displayed on each row, you have to change the line to $nggpictures = ngg_get_search_pictures($keywords, '6');
By default, 4 pictures for each row are displayed. Note that you may also split the code, and put a part before and another part after the <?php while [...] ?> function with the result to display pictures (if relevent) even if there is no post. That’s a bit more advanced, but people with advanced php skills won’t need any complementary explanation to achieve that.
2) Add this code (or this code if you use NexGen 1.0) anywhere in your file functions.php (inside your template folder, create one if you don’t have any)
The code for step on is
Code:
if(is_search()) { $search = $wp_query->get('s'); $keywords = preg_replace('/\+/',' ',$search); if (function_exists ('ngg_get_search_pictures')) { // function from functions.php $nggpictures = ngg_get_search_pictures($keywords, ''); // put the number of pictures by row you want, if you don't want "4" if ($nggpictures) { echo "<h2>Pictures</h2>"; echo $nggpictures; } } }
The code for step 2 is:
Code:
## Function to do searchs on gallery pics from NextGen Gallery plugin ## ## 2 vars : (1) $keywords (usually coming from the standard search query from wordpress) ## (2) $numberPicCol (number of pic by row, if null it takes 4 ) function ngg_get_search_pictures ($keywords, $numberPicRow = NULL) { global $wpdb; $count=1; if (!$numberPicRow) { $numberPicRow = "4"; } $nngquery = " SELECT pid,description,alttext FROM wp_ngg_pictures WHERE MATCH (description, filename, alttext) AGAINST ('*$keywords*' IN BOOLEAN MODE) AND exclude = '0' "; $pictures = $wpdb->get_results($nngquery, ARRAY_A); if ($pictures) foreach($pictures as $pic) { $out .= '<a href="'.nggallery::get_image_url($pic[pid]).'" title="'.stripslashes($pic[description]).'" class="thickbox" rel="singlepic'.$pic[pid].'">'; $out .= '<img class="ngg-singlepic" src="'.nggallery::get_thumbnail_url($pic[pid]).'" alt="'.stripslashes($pic[alttext]).'" title="'.stripslashes($pic[alttext]).'" />'; $out .= "</a>\n"; if ($count == 0) { $out .= "<br />"; } ++$count; $count%=$numberPicRow; } return $out; };
Cheers,
Drew