lyndact
lyndact

Reputation: 1

php - Slider not working in front-page.php in wordpress

I was using a javascript and php slider in html code when it went into wordpress it never worked when it was in html it worked now it says No images found for this slideshow.

header.php javascript

<script>
$(document).ready(function(){
$('#myslides').cycle({
    fit: 1, pause: 0.3
});
});
</script>

front-page.php slider php code

<?php
$directory = 'images/slideshow/';   
try {       
// Styling for images   
echo "<div id=\"myslides\">";   
foreach ( new DirectoryIterator($directory) as $item ) {            
    if ($item->isFile()) {
        $path = $directory . "/" . $item;   
        echo "<img src=\"" . $path . "\" height='200' width='800' />";  
    }
}   
echo "</div>";
}   
catch(Exception $e) {
echo 'No images found for this slideshow.<br />';   
}
?>

Upvotes: 0

Views: 248

Answers (1)

ThemesCreator
ThemesCreator

Reputation: 1759

In WordPress you have to use get_template_directory() to get the path to theme directory, so your directory variable should be:

$directory = get_template_directory() . '/images/slideshow/';

Upvotes: 2

Related Questions