WordPress.org

Forums

using functions.php (theme functions) (2 posts)

  1. richoid
    Member
    Posted 5 years ago #

    I put this in functions.php:

    function superslide_load() {
    		$tdir = 'superheader';
    		$dh  = opendir($tdir);
    		while (false !== ($filename = readdir($dh))) {
    		    $files[] = $filename;
    		}
    
    	        //$dirs = scandir($tdir);
    	        foreach($files as $file) {
    	                if (($file == '.')||($file == '..'))
    	                {
    	                }
    	                elseif (is_dir($tdir.'/'.$file))
    	                {
    	                        filesInDir($tdir.'/'.$file);
    	                }
    	                else
    	                {
    	                      echo  '<div><img src="'. $tdir.'/'.$file.'"/></div>';
    	                }
    	        }
    	}

    I tried calling it (within php tags, in the body of the page.php template) with:

    superslide_load() and also tried:
    <?php if ( function_exists( 'superslide_load' ) ) superslide_load(); ?>

    then I added:
    add_action('wp_head', 'superslide_load');
    to the functions.php (right after the function closed) and tried calling it this way:
    <?php do_action( 'superslide_load', '' ); ?>

    No luck! No errors! Just nothing. Weird because I had this working in MAMP locally (the first sample, above), but can't make it work on the public server.

    Any clues? Thanks!

  2. richoid
    Member
    Posted 5 years ago #

    Another note: I first tried:

    function superslide_load()
    	{	$tdir = 'superheader';
    	        $dirs = scandir($tdir);
    	        foreach($dirs as $file)
    	        {
    	                if (($file == '.')||($file == '..'))
    	                {
    	                }
    	                elseif (is_dir($tdir.'/'.$file))
    	                {
    	                        filesInDir($tdir.'/'.$file);
    	                }
    	                else
    	                {
    	                      echo  '<li><img src="'. $tdir.'/'.$file.'"/></li>';
    	                }
    	        }
    	}

Topic Closed

This topic has been closed to new replies.

About this Topic