Been googling for an hour now can't find the answer to what feels like a simple question.

I have a very basic slideshow. I am using the shortcode to load it into the template page.

[nggallery id=1]

I have also customized the view file gallery.php. Pretty much I just pulled out all the extra stuff and just have the foreach loop.

I have tried using the php shuffle on the $images array but that doesn't fix the problem.

foreach ( $images as $image ) :

Any other ideas?

closed as off-topic by Pieter Goosen, s_ha_dum Oct 15 '14 at 20:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • have you tried - [nggallery id=1 orderby="RAND"] – amit Aug 14 '12 at 18:32
  • I hadn't but I did and it did not resolve the issue. – TJ Sherrill Aug 14 '12 at 18:56

There's a function defined in nggfunctions.php that you can use directly in the template page:

/* nggShowRandomRecent($type, $maxImages, $template, $galleryId) - return recent or random images
 * @access public
 * @param string $type 'id' (for latest addition to DB), 'date' (for image with the latest date), 'sort' (for image sorted by user order) or 'random'
 * @param integer $maxImages of images
 * @param string $template (optional) name for a template file, look for gallery-$template
 * @param int $galleryId Limit to a specific gallery
 * @return the content

Or you can use this shortcode, defined in the shortcodes.php file:

 * Function to show a gallery of random or the most recent images with shortcode of type:
 * [random max="7" template="filename" id="2" /]
 * [recent max="7" template="filename" id="3" mode="date" /]
 * where 
 * - max is the maximum number of random or recent images to show
 * - template is a name for a gallery template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view
 * - id is the gallery id, if the recent/random pictures shall be taken from a specific gallery only
 * - mode is either "id" (which takes the latest additions to the databse, default) 
 *               or "date" (which takes the latest pictures by EXIF date) 
 *               or "sort" (which takes the pictures by user sort order)
 * @param array $atts
 * @return the_content
  • This looks like its what I am looking for. should I simply use that function in my template file? then provide values for those variables? – TJ Sherrill Aug 14 '12 at 21:33
  • Yes, it should work like that. If not, you can also use the shortcode in the template file using the do_shortcode function like this: <?php echo do_shortcode('[random max="7" template="filename" id="1" /]'); ?> – George Grigorita Aug 14 '12 at 21:38
  • That works great. Thanks. Doing this broke the use of jquery cycle through the plugin. IS there something I need to do to put it back? I can ask the question in a new Question if need be – TJ Sherrill Aug 14 '12 at 22:12
  • You mean the slideshow doesn't work anymore? – George Grigorita Aug 15 '12 at 7:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.