RiPro主题美化:导航顶部增加公告滚动条,效果如下
1、找到 wp-content/themes/ripro/fuctions.php 添加如下代码:
//新建快讯功能
add_action('init', 'my_custom_init');
function my_custom_init()
{ $labels = array( 'name' => '快讯',
'singular_name' => '快讯',
'add_new' => '发表快讯',
'add_new_item' => '发表快讯',
'edit_item' => '编辑快讯',
'new_item' => '新快讯',
'view_item' => '查看快讯',
'search_items' => '搜索快讯',
'not_found' => '暂无快讯',
'not_found_in_trash' => '没有已遗弃的快讯',
'parent_item_colon' => '', 'menu_name' => '快讯' );
$args = array( 'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'exclude_from_search' =>true,
'query_var' => true,
'rewrite' => true, 'capability_type' => 'post',
'has_archive' => true, 'hierarchical' => false,
'menu_position' => null, 'supports' => array('editor','author','title', 'custom-fields') );
register_post_type('kuaixun',$args);
}
2、找到 wp-content/themes/ripro/assets/css/diy.css 将如下代码复制进去并保存
.site-header { height: 72px; margin-top: 44px;}
.navFix{margin-top:0px !important;box-shadow:rgba(51,51,51,.2) 0px 2px 3px;position:fixed !important;}
.header-banner{width:100%;background-color:#292a34;height:44px;color:#b2bac2;position:relative;z-index:99;}
.header-banner-content{height:44px;display:flex;align-items:center;justify-content:space-between;font-size:12px}
.deangg{line-height:30px;}
.deanggspan{float:left;width:105px;margin:0 auto;color:#333;font-size:14px;}
.deanggspan i{display:block;float:left;font-size:18px;color:#f60;margin-top:7px;margin-left:5px;margin-right:6px;}
.deanggspan span{display:block;float:left;color:#eee;}
.deangg b{height:12px;margin-top:9px;width:1px;display:block;float:left;background:#a8a8a8;}
.deanggc{float:left;}
.announce-wrap{height:30px;overflow:hidden;}
.deanggc ul{margin-top:-30px;}
.deanggc ul li{font-size:14px;width:580px;display:block;clear:both;height:30px;}
.deanggc ul li a{color:#f60;font-weight:bold;float:left;}
.deanggc ul li a:hover{color:#f60;text-decoration:blink;}
.deanggc ul li span{float:right;color:#999;font-size:12px;width:120px}
3、找到 wp-content/themes/ripro/assets/js/ 上传如下JS文件
/**
+-------------------------------------------------------------------
* jQuery FontScroll - 文字行向上滚动插件 - http://java2.sinaapp.com
+-------------------------------------------------------------------
* @version 1.0.0 beta
* @since 2014.06.12
* @author kongzhim <kongzhim@163.com> <http://java2.sinaapp.com>
* @github http://git.oschina.net/kzm/FontScroll
+-------------------------------------------------------------------
*/
(function($) {
$.fn.FontScroll = function(options) {
var d = { time: 3000, s: 'fontColor', num: 1 }
var o = $.extend(d, options);
this.children('ul').addClass('line');
var _con = $('.line').eq(0);
var _conH = _con.height(); //滚动总高度
var _conChildH = _con.children().eq(0).height(); //一次滚动高度
var _temp = _conChildH; //临时变量
var _time = d.time; //滚动间隔
var _s = d.s; //滚动间隔
_con.clone().insertAfter(_con); //初始化克隆
//样式控制
var num = d.num;
var _p = this.find('li');
var allNum = _p.length;
_p.eq(num).addClass(_s);
var timeID = setInterval(Up, _time);
this.hover(function() { clearInterval(timeID) }, function() { timeID = setInterval(Up, _time); });
function Up() {
_con.animate({ marginTop: '-' + _conChildH });
//样式控制
_p.removeClass(_s);
num += 1;
_p.eq(num).addClass(_s);
if (_conH == _conChildH) {
_con.animate({ marginTop: '-' + _conChildH }, "normal", over);
} else {
_conChildH += _temp;
}
}
function over() {
_con.attr("style", 'margin-top:0');
_conChildH = _temp;
num = 1;
_p.removeClass(_s);
_p.eq(num).addClass(_s);
}
}
})(jQuery);
$(function() {
$('.marquee_box').FontScroll({ time: 5000, num: 1 });
});
4、找到 wp-content/themes/ripro/parts/navbar.php 将如下代码复制到最上面并保存
<div class="header-banner">
<div class="container">
<div class="header-banner-content wrapper">
<div class="deanggwrap">
<div class="deangg comfff wow fadeInUp">
<div class="deanggspan"><i class="fa fa-volume-up"></i>最新公告</div>
<div class="deanggc">
<!--[diy=deanggc]-->
<div class="announce-wrap">
<ul class="announce-list line">
<li style="list-style-type: none;">
<ul class="announce-list line"><!--?php $args = array( 'post_type' => 'kuaixun',<br ?--> 'post_status' => 'publish',</ul>
</li>
</ul>
<ul class="announce-list line">
<li style="list-style-type: none;">
<ul class="announce-list line">'showposts' => '5',</ul>
</li>
</ul>
<ul class="announce-list line">
<li style="list-style-type: none;">
<ul class="announce-list line">);</ul>
</li>
</ul>
<ul class="announce-list line">
<li style="list-style-type: none;">
<ul class="announce-list line">$the_query = new WP_Query( $args );</ul>
</li>
</ul>
<ul class="announce-list line">
<li style="list-style-type: none;">
<ul class="announce-list line">?></ul>
</li>
</ul>
<ul class="announce-list line">
<li style="list-style-type: none;">
<ul class="announce-list line"><!--?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?-->
<li></li>
</ul>
</li>
</ul>
<!--?php endwhile; ?-->
<!--?php wp_reset_postdata(); ?-->
<!--?php else : ?-->
</div>
<!--[/diy]-->
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<div class="header-banner-left">
<div id="ym-menu" class="ym-menu">
<ul id="menu-header-top" class="menu">
<li></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<header id="navHeight" class="site-header">
5、找到 wp-content/themes/ripro/footer.php 将如下内容整体复制并保存
<script>
//内容信息导航吸顶
$(document).ready(function(){
var navHeight= $("#navHeight").offset().top;
var navFix=$("#navHeight");
$(window).scroll(function(){
if($(this).scrollTop()>navHeight){
navFix.addClass("navFix");
}
else{
navFix.removeClass("navFix");
}
})
})
</script>
6、找到 wp-content/themes/ripro/header.php 将如下内容整体复制并保存
<script src="<?php echo get_template_directory_uri() ?>/assets/js/sinabeta.js"></script>
7、进入后台找到快讯菜单-发布快讯,注意:部分用户可能有点样式兼容问题需要自己调整下!
1.使用本站下载的源码仅限于个人学习和非商业用途。
2.禁止将本站下载的源码用于搭建或支持任何违法、淫秽、暴力或侵犯他人合法权益的网站或应用。
3.使用本站下载的源码需遵守国家法律法规及相关规定,不得从事任何违法活动。
4.如若本站内容侵犯了原著者的合法权益,请联系我们进行处理。
评论(0)