導讀:建站技術建站技術一. 在二級目錄上添加文章篇數 在 functions.php 文件上添加下面代碼: 其中的 “<-span .... <-/span>” 請自己去掉減號 “-快速建站技術建站技術。

一. 在二級目錄上添加文章篇數

在 functions.php 文件上添加下面代碼: 其中的 “<-span .... <-/span>” 請自己去掉減號 “-“
感謝 春哥 的幫助
/*?紙模二級分類菜單-文章篇數*/
function?wt_get_category_count($cat_ID)?{
????$category?=?get_category($cat_ID);
????return?$category->count;
}
function?zrz_add_has_children_to_nav_items_num(?$items,$args?){
??????if(isset($args->theme_location)?&&?$args->theme_locdede手機模板ation?==?'header-menu'){
??????foreach?(?$items?as?$item?){
????????$slug?=?str_replace('https://paper.tv/category/','',$item->url);
????????$slug?=?str_replace('/','',$slug);
????????$cat?=?get_category_by_slug($slug);
????????$catID?=?isset($cat->term_id)???$cat->term_id?:?false;
????????if(?$catID){
????????$a=wt_get_category_count($catID);
????????$item->title.=?'<-span?class="num">'.$a.'<-/span>';
????????}
?????}
??}
return?$items;
}
add_filter(?'wp_nav_menu_objects',?'zrz_add_has_children_to_nav_items_num',10,2?);
用于ripro主題
function wt_get_category_count($cat_ID) {
$category = get_category($cat_ID);
return $category->count;
}
function zrz_add_has_children_to_nav_items_num( $items,$args ){
if(isset($args->theme_location) && $args->theme_location == 'main'){
關鍵詞標簽: 建站 篇數 菜單
聲明: 本文由我的SEOUC技術文章主頁發布于:2023-07-23 ,文章7B2主題菜單上添加文章篇數,建站技術主要講述篇數,菜單,建站網站建設源碼以及服務器配置搭建相關技術文章。轉載請保留鏈接: http://www.bifwcx.com/article/web_34809.html