foreach ( new DirectoryIterator($img_directory) as $item ) not working
-
Does anyone see anything wrong with this slideshow code for a template. Trying to read in files from an image folder for a slideshow. Gets hung up after
<div id="myslides">
Here is my test template (BTW I’m kind of new at WP template programming so tips are appreciated). Code is all tested and working outside of WP:
<?php /* Template Name: Custom Interior Page */ list($bfa_ata, $cols, $left_col, $left_col2, $right_col, $right_col2, $bfa_ata['h_blogtitle'], $bfa_ata['h_posttitle']) = bfa_get_options(); get_header(); extract($bfa_ata); global $bfa_ata_postcount; ?> <script src="../../scripts/jquery-1.7.2.min.js" type="text/javascript"></script> <script src="../../scripts/jquery.cycle.lite.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $('#myslides').cycle({ fit: 1, pause: 1, timeout: 4000 }); }); </script> <style> #myslides { height:400px; width:600px; } </style> <div id="interior_wrapper"> <?php global $post; $post_slug=$post->post_name; $img_directory = '../../images/'.$post_slug; // echo $directory; // Styling for images echo '<div id="myslides">'; foreach ( new DirectoryIterator($img_directory) as $item ) { if ($item->isFile()) { $path = $img_directory . '/' . $item; echo '<img src="' . $path . '"/>'; } } echo '</div>'; ?> </div> <?php get_footer(); ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘foreach ( new DirectoryIterator($img_directory) as $item ) not working’ is closed to new replies.