目標:隱藏特定類別,使其不顯示在帖子元區域中下面的代碼實現了這一點(在主題的 functions.php 文件中):function exclude_these_categories($thelist, $separator=' ') { //Exclude the following categories $exclude = array('Category 1', 'Category 2', 'Category 3', 'Category 4', 'Category 5', 'Category 6'); $cats = explode($separator, $thelist); $newlist = array(); foreach($cats as $cat) { $catname = trim(strip_tags($cat)); if(!in_array($catname, $exclude)) $newlist[] = $cat; } return implode($separator, $newlist);}add_filter('the_category','exclude_these_categories', 10, 2);但是,它會在編輯時隱藏所有類別,而不僅僅是上面提到的特定類別: missing categories screenshot我需要一個解決方案,這樣如果有人登錄,上面的代碼就不會運行;或添加到代碼中,以便在編輯時顯示類別。
如果用戶已登錄,則需要腳本不運行
白豬掌柜的
2023-04-27 16:31:38