Hi,
I need exactly this function.
I change the e funciton in the tags.php file like this (word in bold). I’m not a good php programer and i’m sure my code is not the better one, but the result is ok 🙂
function find_images_for_tags($taglist, $mode = “ASC”) {
// return the images based on the tag
global $wpdb;
// check separator ‘,’ or ‘+’
if (strpos($taglist, ‘+’) === false) {
// extract it into a array
$taglist = explode(“,”, $taglist);
$separ = false;
} else {
// extract it into a array
$taglist = explode(“+”, $taglist);
$separ = true;
}
if ( !is_array($taglist) )
$taglist = array($taglist);
$taglist = array_map(‘trim’, $taglist);
$new_slugarray = array_map(‘sanitize_title’, $taglist);
$sluglist = “‘” . implode(“‘, ‘”, $new_slugarray) . “‘”;
// first get all $term_ids with this tag
$term_ids = $wpdb->get_col( $wpdb->prepare(“SELECT term_id FROM $wpdb->terms WHERE slug IN ($sluglist) ORDER BY term_id ASC “));
if ( $separ ) {
$picids = get_objects_in_term($term_ids[0], ‘ngg_tag’);
for ( $i=1; $i<count($term_ids); $i++ ){
$picids = array_intersect($picids, get_objects_in_term($term_ids[$i], ‘ngg_tag’));
}
} else {
$picids = get_objects_in_term($term_ids, ‘ngg_tag’);
}
//Now lookup in the database
if ($mode == ‘RAND’)
$pictures = nggdb::find_images_in_list($picids, true, ‘RAND’ );
else
$pictures = nggdb::find_images_in_list($picids, true, ‘ASC’ );
return $pictures;
}
using the tags is now :
[nggtags gallery=thailand,rate_1] the same as before !
[nggtags gallery=thailand+rate_1] only picture with the two tags
hope this help
Thread Starter
rauhe
(@rauhe)
Great! exactly what i was looking for. I cant test it right now but will try it when i get a chance……
Thanks!
John
Excellent, merci beaucoup, c’est LE code que je cherchais depuis longtemps !!!
Excellent, thank’s a lot, this THE code I searching for a long time !!!
… and, otherwise, is there a way to exclude a tag ?
Like this for exemple : [nggtags gallery=thailand-rate_1] all the pictures with thailand tag but without rate_1