下载 select-tree.js 文件,下载地址:
https://work100.com.cn/wp-content/themes/zibll/js/libs/select-tree.js
https://work100.com.cn/wp-content/themes/zibll/css/select-tree.css
文件下载完成后放入对应的文件夹
在文件 wp-content/themes/zibll/inc/functions/zib-theme.php 中修改代码,在759行替换如下代码
_cssloader(array(
'bootstrap' => isset($css[$js_outlink]['bootstrap']) ? $css[$js_outlink]['bootstrap'] : 'bootstrap.min',
'fontawesome' => isset($css[$js_outlink]['fontawesome']) ? $css[$js_outlink]['fontawesome'] : 'font-awesome.min',
'main' => 'main.min',
'select' => 'select-tree',
));
在790行插入如下代码
wp_enqueue_script('select', ZIB_TEMPLATE_DIRECTORY_URI . '/js/libs/select-tree.js', array('jquery'), THEME_VERSION, true);
在文件 wp-content/themes/zibll/pages/newposts.php 中,194 – 213 行代码替换如下:
<select class="form-control" id="category" name="category" tabindex="5">
<?php
$cat_ids = _pz('post_article_cat', array());
$cats = get_categories(array(
'orderby' => 'include',
'include' => $cat_ids,
'hide_empty' => false,
));
if ($cats) {
foreach ($cats as $cat) {
echo '<option value="' . $cat->term_id . '" ' . selected($cat->term_id, $in['cat_id'], false) . ' data-pid="'.$cat->parent.'">' . $cat->name . '</option>';
}
} else {
echo '<option value="1" selected="selected">' . get_category(1)->name . '</option>';
}
?>
</select>
在此文件末尾增加
?>
<script>
$("#category").selectTree();
</script>
或者直接使用懒人包,下载附件,覆盖对应的文件即可
© 版权声明
THE END
请登录后查看评论内容