nggShowRelatedImages

NggShowRelatedImages() - return related images based on category or tags.

Description

nggShowRelatedImages( (string) $type = '', (int) $maxImages = 0 ); 

Parameters (2)

0. $type — Optional. (string) => ''
Could be tags or category
1. $maximages (int)
The maximages.

Usage

  1. if ( !function_exists( 'nggShowRelatedImages' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextcellent-gallery/nggfunctions.php'; 
  3.  
  4. // could be 'tags' or 'category' 
  5. $type = ''; 
  6.  
  7. // The maximages. 
  8. $maximages = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = nggShowRelatedImages($type, $maximages); 
  12.  

Defined (1)

The function is defined in the following location(s).

/nggfunctions.php  
  1. function nggShowRelatedImages($type = '', $maxImages = 0) { 
  2. $ngg_options = nggGallery::get_option(ngg_options); 
  3.  
  4. if ($type == '') { 
  5. $type = $ngg_options['appendType']; 
  6. $maxImages = $ngg_options['maxImages']; 
  7.  
  8. $sluglist = array(); 
  9.  
  10. switch ($type) { 
  11. case 'tags': 
  12. $taglist = get_the_tags(); //Return array of tag objects, false on failure or empty 
  13. //This is a tag list for posts non Nextcellent tag lists. 
  14. if (!$taglist) return ""; 
  15. foreach ($taglist as $tag) { 
  16. $sluglist[] = $tag->slug; 
  17. break; 
  18.  
  19. case 'category': 
  20. $catlist = get_the_category(); //return array (empty if no categories) 
  21. if (empty ($catlist)) return ""; 
  22. foreach ($catlist as $cat) { 
  23. $sluglist[] = $cat->category_nicename; 
  24. break; 
  25. $sluglist = implode(', ', $sluglist); 
  26. $out = nggShowRelatedGallery($sluglist, $maxImages); 
  27. return $out;