汇聚访-汇聚访
汇聚访的头像-汇聚访
UID:1 已加入汇聚访256天 总消费:0 徽章-身份唯一-汇聚访徽章-收藏新秀-汇聚访徽章-不败赞神-汇聚访11枚徽章河南省漯河市管理员
2025-12-14
12-14
子比主题 - 新文章轮播小工具-汇聚访

实用子比主题 – 新文章轮播小工具

这是一款适配于子比主题的新文章轮播小工具,此小工具是左一右二排列的,同时此小工具还可以自定义轮播的文章ID以及是否显示作者、日期等相关信息,同时还可以单独设置每个轮播组件的切换效果,有需要的朋友自行部署吧! 演示效果: 代码部署: [hidecontent type="reply"] 定位:/wp-content/themes/zibll/func.php添加以下代码即可: Zib_CFSwidget::create('zib_widget_new_carousel',array('title'=>'New轮播图','zib_title'=>true,'zib_affix'=>true,'zib_show'=>true,'description'=>'左侧轮播+右侧双栏,支持5种切换效果','fields'=>array(array('id'=>'height','type'=>'number','title'=>'模块高度','default'=>400,'unit'=>'px'),array('id'=>'right_width','type'=>'number','title'=>'右侧宽度','default'=>300,'unit'=>'px'),array('id'=>'left_posts','type'=>'text','title'=>'左侧文章ID','desc'=>'多个用逗号分隔,留空自动获取'),array('id'=>'right_top_posts','type'=>'text','title'=>'右上文章ID','desc'=>'多个用逗号分隔,留空自动获取'),array('id'=>'right_bottom_posts','type'=>'text','title'=>'右下文章ID','desc'=>'多个用逗号分隔,留空自动获取'),array('id'=>'left_effect','type'=>'select','title'=>'左侧切换效果','options'=>array('slide'=>'滑动','fade'=>'淡出淡入','cube'=>'3D方块','coverflow'=>'3D滑入','flip'=>'3D翻转'),'default'=>'slide'),array('id'=>'right_top_effect','type'=>'select','title'=>'右上切换效果','options'=>array('slide'=>'滑动','fade'=>'淡出淡入','cube'=>'3D方块','coverflow'=>'3D滑入','flip'=>'3D翻转'),'default'=>'fade'),array('id'=>'right_bottom_effect','type'=>'select','title'=>'右下切换效果','options'=>array('slide'=>'滑动','fade'=>'淡出淡入','cube'=>'3D方块','coverflow'=>'3D滑入','flip'=>'3D翻转'),'default'=>'fade'),array('id'=>'autoplay','type'=>'switcher','title'=>'自动播放','default'=>true),array('id'=>'interval','type'=>'number','title'=>'播放间隔(秒)','default'=>4,'dependency'=>array('autoplay','==',true)),array('id'=>'show_info','type'=>'checkbox','title'=>'显示信息','inline'=>true,'options'=>array('show_author'=>'作者','show_date'=>'日期','show_category'=>'分类','show_tags'=>'标签'),'default'=>array('show_author','show_date','show_category')),array('id'=>'text_style','type'=>'fieldset','title'=>'文字样式','inline'=>true,'fields'=>array(array('id'=>'title_length','type'=>'number','title'=>'标题字数','default'=>30),array('id'=>'excerpt_length','type'=>'number','title'=>'摘要字数','default'=>50),array('id'=>'text_shadow','type'=>'switcher','title'=>'文字阴影','default'=>true)))))); function zib_widget_new_carousel($args,$instance){if(!Zib_CFSwidget::show_class($instance))return;$cfg=array_merge(array('height'=>400,'right_width'=>300,'left_effect'=>'slide','right_top_effect'=>'fade','right_bottom_effect'=>'fade','autoplay'=>true,'interval'=>4,'show_info'=>array(),'text_style'=>array()),$instance);$show_cfg=array_flip($cfg['show_info']);$posts=array('left'=>nc_get_posts($cfg['left_posts']??'',5),'top'=>nc_get_posts($cfg['right_top_posts']??'',3),'bottom'=>nc_get_posts($cfg['right_bottom_posts']??'',3));if(!array_filter($posts))return;$id='nc-'.uniqid();$shadow=($cfg['text_style']['text_shadow']??true)?'text-shadow:1px 1px 2px rgba(0,0,0,0.8);':'';Zib_CFSwidget::echo_before($instance);echo'<div class="new-carousel-wrap" id="'.$id.'">';$areas=array('left'=>array('height'=>$cfg['height'],'class'=>'nc-left-wrap','pagination'=>true,'button'=>true,'effect'=>$cfg['left_effect'],'interval'=>$cfg['interval']*1000),'top'=>array('height'=>($cfg['height']-10)/2,'class'=>'nc-right-top-wrap','pagination'=>true,'button'=>false,'effect'=>$cfg['right_top_effect'],'interval'=>$cfg['interval']*1000+1000),'bottom'=>array('height'=>($cfg['height']-10)/2,'class'=>'nc-right-bottom-wrap','pagination'=>true,'button'=>false,'effect'=>$cfg['right_bottom_effect'],'interval'=>$cfg['interval']*1000+2000));if($posts['left']){echo'<div class="nc-left-wrap">';nc_render_slider($posts['left'],$areas['left'],$show_cfg,$cfg['text_style'],true);echo'</div>';}if($posts['top']||$posts['bottom']){echo'<div class="nc-right-wrap">';if($posts['top']){echo'<div class="nc-right-top-wrap">';nc_render_slider($posts['top'],$areas['top'],$show_cfg,$cfg['text_style'],false);echo'</div>';}if($posts['bottom']){echo'<div class="nc-right-bottom-wrap">';nc_render_slider($posts['bottom'],$areas['bottom'],$show_cfg,$cfg['text_style'],false);echo'</div>';}echo'</div>';}echo'</div><style>#'.$id.'{display:flex;gap:10px;height:'.$cfg['height'].'px;border-radius:8px;overflow:hidden}#'.$id.' .nc-left-wrap{flex:1;position:relative;border-radius:8px;overflow:hidden}#'.$id.' .nc-right-wrap{width:'.$cfg['right_width'].'px;display:flex;flex-direction:column;gap:10px}#'.$id.' .nc-right-top-wrap,#'.$id.' .nc-right-bottom-wrap{flex:1;position:relative;border-radius:8px;overflow:hidden}#'.$id.' .zib-slider{height:100%}#'.$id.' .new-swiper{height:100%;border-radius:8px;overflow:hidden}#'.$id.' .nc-right-top-wrap .swiper-pagination,#'.$id.' .nc-right-bottom-wrap .swiper-pagination{bottom:8px}#'.$id.' .nc-right-top-wrap .swiper-pagination-bullet,#'.$id.' .nc-right-bottom-wrap .swiper-pagination-bullet{width:6px;height:6px;margin:0 3px}#'.$id.' .swiper-slide::before{content:"";position:absolute;bottom:0;left:0;right:0;height:30%;background:linear-gradient(to top,rgba(0,0,0,0.5)...
热评