WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Determine number of objects & select one at random (2 posts)

  1. xrun
    Member
    Posted 2 years ago #

    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.

  2. xrun
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic