Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

shuffle($images);
foreach ( $images as $image ) :

Any other ideas?

share|improve this 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

1 Answer 1

up vote 1 down vote accepted

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
 */
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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