Created
April 3, 2015 00:54
-
-
Save scmorrison/cff4c7156beb98a04aa3 to your computer and use it in GitHub Desktop.
wp-content/themes/THEME/functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Include nggallery images in search results | |
** Search 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 = "4") { | |
global $wpdb; | |
global $nggdb; | |
$count=1; | |
$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) { | |
$image = $nggdb->find_image( $pic['pid'] ); | |
$out .= '<a href="'.$image->imageURL.'" title="'.stripslashes($pic['description']).'" class="thickbox" rel="singlepic'.$pic['pid'].'">'; | |
$out .= '<img class="ngg-singlepic" src="'.$image->thumbURL.'" alt="'.stripslashes($pic[alttext]).'" title="'.stripslashes($pic['alttext']).'" />'; | |
$out .= "</a>\n"; | |
if ($count == 0) { | |
$out .= "<br />"; | |
} | |
++$count; | |
$count%=$numberPicRow; | |
} | |
return $out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment