NextGEN Gallery
[resolved] Question about shortcodes, how to show 1 random image on a page (11 posts)

  1. Jeroen
    Posted 3 years ago #

    I am trying to figure out how to work with the new shortcodes.

    What I want is to be able to show 1 random image from one or more galleries on my frontpage.

    I believe the new shortcodes should be able to do this, but I can't get it to work. Here is the shortcode I believe to be correct, however it always shows the first image of the gallery.

    [ngg_images gallery_ids="3" source=”random” display_type="photocrati-nextgen_basic_singlepic"]



  2. Benjamin
    Posted 3 years ago #

    I don't think there is a way to make singlepic load anything other than individual images. It's a bit cludgy but the following should work:
    [ngg_images image_ids='1,2,3,4' order_by='rand()' display_type='photocrati-nextgen_basic_singlepic']

  3. Jeroen
    Posted 3 years ago #

    Great suggestion Benjamin! The order_by="rand()" works for me. Now I only need to tweak the singlepic template to get it to my liking :-)


  4. renambot
    Posted 3 years ago #

    Combining your two codes made it work for me, picking one random image within a gallery:
    [ngg_images gallery_ids='3' order_by='rand()' display_type='photocrati-nextgen_basic_singlepic']

    I'm guessing singlepic takes the first (or last image) and the sorting option makes it random.

    The example in the doc doesn't seem to work (or is misleading).


  5. Jeroen
    Posted 3 years ago #

    You are right Luc, maybe it would be good to add this to the documentation.

  6. bermannyc
    Posted 2 years ago #

    I was having the same problem following the random image shortcode from the Photocrati site. The order_by='rand()' code worked for me.

  7. stephane LP
    Posted 2 years ago #

    I use your code like this :
    [ngg_images gallery_ids='7,8,9,10,11,12,13,15,16,17,18,19,20' order_by='rand()' display_type='photocrati-nextgen_basic_singlepic' height='500' width='400']

    but if someone can tell me to put all galeries but exlude the 14's ID it will be very fine !
    like :
    gallery_ids="random" exclusions='14'


  8. bermannyc
    Posted 2 years ago #


    I'm having problems with the code here. Currently I'm using this code on my front page:

    [ngg_images tag_ids='front' order_by='rand()' display_type='photocrati-nextgen_basic_singlepic']

    It's supposed to pick a random image with the tag "front" on it and display it as the main image on the front page. The problem is that it's not very random. Every time I reload the page it displays the same image. Even in separate browsers it still displays the same image.

    What am I doing wrong here? It's driving me a little crazy.

    my site: http://www.brianbermanphoto.com

  9. bermannyc
    Posted 2 years ago #

    also, I've tried using random_max'1' in place of the order_by short code and that also doesn't work.

  10. mccomb
    Posted 2 years ago #

    @bermannyc - I'm having the same issue. It loads different images on different pages, but always the same image on the same page, so it is not randomly loading new ones on page refresh which is what I want it to do.

    Anyone get that working?

  11. bermannyc
    Posted 2 years ago #

    I think it could be something related to the cache not being emptied. I know there's been some problems with Next Gen post 2.0 update so maybe this is one of them? There was a new beta released with some cache related fixes so this could possibly be one of them?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • NextGEN Gallery
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic