2
我使用Sly Slider和免費的wordpress主題。我已經正確入選了js文件,設置了html標記,並根據文檔編寫了一個jquery函數,但似乎無法讓其立即運行。我錯過了什麼;Sly Slider init
我的PHP函數:
function sly_slider()
{
$args = array(
'post_type' => 'yacht',
'posts_per_page' => -1
);
$yachts = get_posts($args);
echo '<div class="frame" id="frame">';
echo '<ul class="slidee">';
foreach ($yachts as $yacht) {
$id = $yacht->ID;
$image = get_the_post_thumbnail($id, 'post-thumbnail');
$title = get_the_title($yacht);
$excerpt = get_the_excerpt();
echo '<li class="yacht-slider-item">';
echo '<h5 class="yacht-slider-title">'. $title .'</h5>';
echo $image;
echo $excerpt;
echo '</li>';
}
echo '</ul>';
echo '</div>';
}
我的CSS(根據DOC):
.frame { padding: 0; width: 300px; height: 400px; }
.frame .slidee { margin: 0; padding: 0; width: 100%; list-style: none; }
.frame .slidee li { float: left; margin: 0 0 5px 0; padding: 0; width: 100%; height: 100px; }
我jQuery的功能:
function sidebar_sly()
{
var options = {
slidee = '.slidee',
itemSelector: 'li',
horizontal: 0,
itemNav: 'basic',
speed: 800,
activatePageOn: 'click',
cycleBy: 'pages',
cycleInterval: 5000,
startPaused: false,
pageBuilder: function() {
return '<li></li>';
}
};
var sly = new Sly(frame, options, callbackMap).init();
jQuery('#frame').sly(options);
}
是啊,我剛剛做了這一點,現在的工作。更正了「slidee =」選項。感謝您的快速回答@Chitrang。 – vagelis