获取当前文章父级分类别名

Use the ID value returned by $category[0]->category_parent and pass it through get_term(). Example:

$category = get_the_category(); 
$category_parent_id = $category[0]->category_parent;
if ( $category_parent_id != 0 ) {
    $category_parent = get_term( $category_parent_id, 'category' );
    $css_slug = $category_parent->slug;
} else {
    $css_slug = $category[0]->slug;
}

自动获取序号

html:

<ul class="num">
        <li><span></span></li>
        <li><span></span></li>
        <li><span></span></li>
        <li><span></span></li>
        <li><span></span></li>
        <li><span></span></li>
        <li><span></span></li>
        <li><span></span></li>
        <li><span></span></li>
        <li><span></span></li>
        <li><span></span></li>
        <li><span></span></li>
</ul>

js:

function addNum() {
var $items = $('.num').find('li').length;
for( var $i = 0; $i < $items; $i++) {
var a = $i + 1;
if(a<10){
$('.num').find('li').eq($i).find('span').html(a).prepend('0');}
else{
$('.num').find('li').eq($i).find('span').html(a);
}
}
}
$(function() {addNum();})

获取hash值页面跳转

js部分

//获取hash值
var $staff_id = window.location.hash;
//提取字符串
var $staff_flag = $staff_id.substr(1, 5);
if ($staff_id.length && ($staff_flag == "staff")) {
//选择对象
$staff_id = $staff_id.replace('#','.');
var $this = $staff_id ;

//coding here 

}