Title: Dynamic Gallery Generation Using PHP
Last modified: May 25, 2017

---

# Dynamic Gallery Generation Using PHP

 *  [vanguardclimate](https://wordpress.org/support/users/vanguardclimate/)
 * (@vanguardclimate)
 * [9 years ago](https://wordpress.org/support/topic/dynamic-gallery-generation-using-php/)
 * I am trying to automate the generation of dynamic HTML content to list a directory
   structure that contains thousands of image files and will provide a single directory
   listing for all directories at the top level. I have the top level directory 
   listing working so that there are placeholders for links to all folders. I do
   not want to generate index files in every folder or have to manually create 700
   + galleries. The directory contents need to be treated as an external-owned repository
   that cannot be modified and that will change independently of the dynamically
   generated listings that automatically adjust to changes in the content of the
   repository. I would like to generate the listings of image files for each folder
   on the fly using the link to each folder from the top level directory listing.
   I have no problem to generate the content I need with a hard coded path inside
   the PHP. I am able to accomplish both sides of the problem, but cannot find a
   way to bind the top level listing page to the PHP that generates the list of 
   images. I have tried to do it by passing the folder name through a URL, but when
   it gets inside the PHP, it does not allow read access to the folder, apparently
   because the PHP is called from the front end. Is there another way that the PHP
   can be invoked so that content can be dynamically created on the backend by the
   user activating a link on the front end and then displayed? Is there a way a 
   link can be encoded on the front end that does not cause this problem? Or should
   it be able to work the way I now have it configured? I have not coded with jquery
   and if there is a way to do this with jquery or some javascript, I need an example
   to follow. Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Dat Nguyen](https://wordpress.org/support/users/blacker92/)
 * (@blacker92)
 * [9 years ago](https://wordpress.org/support/topic/dynamic-gallery-generation-using-php/#post-9166122)
 * You should present the question more clearly.I think you are blogging….
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years ago](https://wordpress.org/support/topic/dynamic-gallery-generation-using-php/#post-9171350)
 * PHP should be able to determine the file/folder structure through the usual filesystem
   functions and generate a user interface accordingly. If PHP is denied access,
   either PHP was not initiated properly so that it’s running under the wrong user,
   or there’s a file permissions problem in general, or your server is running mod_security
   or similar where access is arbitrarily blocked under specific circumstances.
 * If it is something like mod_security, you’ll need to work with your host to allow
   your script access. You said you tried passing folder names through URLs. Where
   does the URL go? If your own PHP file, the code may be running under a different
   server user (not WP user) than the one used by WP. If your PHP uses any WP resources,
   you shouldn’t be requesting PHP files directly, you should go through the WP 
   system so WP can be properly initiated. There are limited ways to do this. One
   is by requesting a WP page by permalink that’s based on a custom template containing
   your code. The other options are Ajax and going through /wp-admin/admin-post.
   php. Somehow including wp-load.php or blog-header.php in your PHP is Doing it
   Wrong™

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Dynamic Gallery Generation Using PHP’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 3 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [9 years ago](https://wordpress.org/support/topic/dynamic-gallery-generation-using-php/#post-9171350)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
