我已经自定义了平滑的div滚动jquery插件(http://smoothdivscroll.com/)并将其作为wordpress插件在wordpress中实现,同时还有一个选项页面,您可以在此处查看滑块http://dev.linuxfreakz.com/?page_id=2,我在wordpressadmin中创建了一个选项页面,其中有4个选项来选择滑块标题、背景和箭头颜色以及帖子类别。幻灯片是wordpress的帖子,里面的图片是他们的特色图片。滑块目前可以与短代码一起使用,这一切都很好,而且可以工作。
问题是,现在我应该添加多个滑块,这些滑块可以选择不同的选项,并且可以通过选项页面在单个页面上使用,我很困惑如何做到这一点。一些wordpress大师能告诉我正确的方向吗?我真的没有时间了,我不需要整个代码,只需要一个如何真正完成这项工作的想法,我自己通常非常擅长php和wordpress。
任何帮助都将不胜感激,谢谢。
这是我当前使用的拉帖子和生成滑块的代码
function sds_display_slider() {
global $post;
$sds_category2 = (get_option('sds_category') != false) ? get_option('sds_category') : 1;
$sds_title2 = (get_option('sds_title') != '') ? get_option('sds_title') : 'Smooth Slider';
$sds_bgcolor2 = (get_option('sds_bgcolor') != '') ? get_option('sds_bgcolor') : '#dedede';
$sds_navcolor2 = (get_option('sds_navcolor') != '') ? get_option('sds_navcolor') : '#9e1b32' ;
$plugins_url = plugins_url();
echo '<div id="carousel" style="background-color:'.$sds_bgcolor2.'!important;">
<style>
div.scrollingHotSpotLeft {background-color:'.$sds_navcolor2.';}
div.scrollingHotSpotRight{background-color:'.$sds_navcolor2.';}
</style>
<h2>'.$sds_title2.'</h2>
<div id="makeMeScrollable">';
query_posts('post_type=post&posts_per_page=-1&cat='.$sds_category2.'&order=ASC');
if ( have_posts() ) :while ( have_posts() ) : the_post();
$img_attached_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium');
$img_attached = $img_attached_url[0];
$post_heading = get_the_title($post->ID);
$post_text = substr(get_the_excerpt(),0,180)."...";
$link = get_permalink($post->ID);
echo '<div class="contentBox">
<a href="'.$link.'">
<img src="'.$img_attached.'"></a><br>
<a href="'.$link.'"><h2>'.$post_heading.'</h2></a>
<p>'.$post_text.'</p>
</div>';
endwhile;
endif;wp_reset_query();
echo '</div>
</div>';
}
尝试http://wordpress.org/plugins/meta-box/把你的选项页放进去。