Forums

How do I display all the images in a folder? (2 posts)

  1. Tom Kroscavage
    Member
    Posted 3 years ago #

    Say I had a post or page that was called interesting stuff. Is there a way I can display all the images from a folder called interesting stuff? Changing the contents of the folder would change the photos being displayed on the post or page.

    I found this searching the web:
    <?php
    $files = glob("images/*.*");
    for ($i=1; $i<count($files); $i++)
    {
    $num = $files[$i];
    echo '<img src="'.$num.'" alt="random image">'."  ";
    }
    ?>

    But I have never been able to get php code to run inside a post or page.

  2. RoseCitySister
    Member
    Posted 3 years ago #

    You can't use PHP in the editor. Why don't you use NextGen Gallery? You would be able to create an album called Interesting Stuff and display it in your posts or pages. Or if you preferred, you could post single pictures or whole galleries.

    It's an awesome plugin - little bit of a learning curve but still very nice.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.