• Hello,

    I’ve been having trouble properly outputting the directory for images in a slider using Custom Fields. The code I’m using is following:

    <div class="container">
    			    	<?php
    			    				//path or directory where the images are stored
    			    				$directory = "echo get_post_meta($post->ID, 'directory', true)";
    
    			    				//read all files with a .jpg extension
    			    				$images = glob($directory . "*.jpg");
    
    			    				//output the required HTML code to display the images in the gallery
    			    				foreach($images as $image)
    			    				{
    			    					echo '<div class="content"><div><a href="'.$image.'"><img src="'.$image.'" width="120" height="80" alt="this is a test" class="thumb" /></a></div></div>'."\n";
    			    				}
    			    			?>
    			</div>

    The value I want to dynamically output is the $directory = “”, where it would normally be something like $directory = “images/product1/”. I have my custom field ‘directory’ set as images/product1/. Any ideas? Thanks for the help!

  • The topic ‘Help with Custom Fields in PHP’ is closed to new replies.