WordPress.org

Support

Support » Themes and Templates » opendir folder path issue

opendir folder path issue

  • I can’t seem to get WP to recognize correct image folder path. Anybody see anything wrong with this??

    <?php
    
        global $post;
        $post_slug=$post->post_name;
    
    	$img_directory = bloginfo("template_directory");
    	$img_directory .= '/images/'.$post_slug;
    	echo $img_directory;
    	// Styling for images
    	echo '<div id="myslides">';
    	if ($handle = @opendir($img_directory) or die("There is an error with your image directory!")) {
    		while (false !== ($file = readdir($handle))) {
        		if (strpos($file, ".jpg")) {
    				$path = $img_directory . '/' . $file;
    				echo '<img src="' . $path . '"/>';
        		}
    		}
    		closedir($handle);
    	}
    	echo '</div>';
    ?>
  • The topic ‘opendir folder path issue’ is closed to new replies.