Support » Plugins » Determine number of objects & select one at random

  • Resolved xrun


    Hi, seasons greetings from Norway. 🙂

    I need to determine the number of objects (txt files, images or other content) in a folder, and select one of them at random. This object will then be shown in a sidebar that is not populated by other widget from the control panel. I have code in the relevant sidebars in the templates to fetch a php-file which should determine and show this random content.
    I imagine something similar is used to display random pictures in the heading of the Twentyeleven theme, except from the part determining the number of pictures.

    Any ideas on how to code this?

    Edit: It would be great if the selected object could be logged as shown each time it’s shown as well, but that’s not the most important thing right now.

Viewing 1 replies (of 1 total)
  • Alternatively: determine the number of images in a folder, then randomly pick one to display, under the condition that it has not been shown during the last (number of images) times an image was shown. This would ensure that all got equal exposure on the page, but still display them in a mostly random order.

Viewing 1 replies (of 1 total)
  • The topic ‘Determine number of objects & select one at random’ is closed to new replies.