php - 滑块在wordpress

时间:2015-10-12 21:33:42

标签: javascript php jquery html wordpress

我在html代码中使用了javascript和php滑块,当它进入wordpress时它从未在html中工作,它现在工作它说没有为此幻灯片显示找到图像。

header.php javascript

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

front-page.php滑块php代码

<?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 />';   
}
?>

1 个答案:

答案 0 :(得分:2)

在WordPress中,您必须使用<template name="updateCustomerProfile"> <div class="container"> <h1>Edit User</h1> {{#with currentUser}} {{#autoForm collection="Users" doc=this id="profileForm" type="update"}} <fieldset> {{> afQuickField name='username'}} {{> afObjectField name='profile'}} </fieldset> <button type="submit" class="btn btn-primary">Update User</button> <a class="btn btn-link" role="button" href="{{pathFor 'adminDocuments'}}">Back</a> {{/autoForm}} {{else}} Nothing {{/with}} </div> </template> 来获取主题目录的路径,因此您的目录变量应为:

get_template_directory()