The MU forums have moved to WordPress.org

Show random thumbnail image of Template in Homepage (8 posts)

  1. yyvonne
    Member
    Posted 15 years ago #

    Does anyone has a plugin to show a random thumbnail image of a template in Homepage?

  2. dsader
    Member
    Posted 15 years ago #

  3. yyvonne
    Member
    Posted 15 years ago #

    Actually what I mean is just a random template thumbnail image (screenshot.png) from wp-content/themes.

    Something like List-All-Posts, but it's List-Random-Template screenshot.

  4. dsader
    Member
    Posted 15 years ago #

    If its only the screenshot you are after, this works.

    Copy every theme screenshot to one folder, then use a normal random image-type plugin such as http://wordpress.org/extend/plugins/random-image-selector/

    Hmm, tedious to rename all screenshots, though.

    Try a recursive read/find/array_slice/echo on the themes dir, did something similar in php this week.

  5. dsader
    Member
    Posted 15 years ago #

    Here's some code I've added directly into an index.php to show one random screenshot.png from the themes dir.

    http://pastebin.com/m6ab280a7

    Oop forgot array_slice and a shuffle if you ever wanted more than one

    http://pastebin.com/m68a05b2e

  6. yyvonne
    Member
    Posted 15 years ago #

    Great!

    However, I am not able to put this at my sidebar. Any solution?

  7. dsader
    Member
    Posted 15 years ago #

    Wrap everything in functions {} and it'll fly in a sidebar. You can put any functions into your template functions.php and then call the output function in the sidebar.

    http://pastebin.com/mc003956

  8. yyvonne
    Member
    Posted 15 years ago #

    Excellent! Thank you so much!

About this Topic