導讀:建站技術建站技術天要介紹的是No Category Base插件,百度貌似對三級目錄的收錄不喜,它的功能就是刪除分類目錄鏈接中/category/?那有些多余的字樣。若單單為了網站如何搭建建站的技術。

天要介紹的是No Category Base插件,百度貌似對三級目錄的收錄不喜,它的功能就是刪除分類目錄鏈接中/category/?那有些多余的字樣。若單單為了SBO而再多裝一個插件實在不值,不如……把它集成到主題中?
加入該代碼至主題文件functions.php:
//去除分類標志代碼
add_action( 'load-themes.php', 'no_category_base_refresh_rules');
add_action('created_category', 'no_category_base_refresh_rules');
add_action('edited_category', 'no_category_base_refresh_rules');
add_action('delete_category', 'no_category_base_refresh_rules');
function no_category_base_refresh_rules() {
global $wp_rewrite;
$wp_rewrite -> flush_rules();
}
// register_deactivation_hook(__FILE__, 'no_category_base_deactivate');
// function no_category_base_deactivate() {
// remove_filter('category_rewrite_rules', 'no_category_base_rewrite_rules');
// // We don't want to insert our custom rules again
// no_category_base_refresh_rules();
// }&dede,模板nbsp;
// Remove category base
add_action('init', 'no_category_base_permastruct');
function no_category_base_permastruct() {
global $wp_rewrite, $wp_version;
if (version_compare($wp_version, '3.4', '<')) {
&dede5.7模板nbsp; // For pre-3.4 support
$wp_rewrite -> extra_permastructs['category'][0] = '%category%';
} else {
$wp_rewrite -> extra_permastructs['category']['struct'] = '%category%';
}
關鍵詞標簽: 建站 插件 標志
聲明: 本文由我的SEOUC技術文章主頁發布于:2023-07-23 ,文章wordpress教程:免插件實現No Category Base效果:,建站主要講述插件,標志,建站網站建設源碼以及服務器配置搭建相關技術文章。轉載請保留鏈接: http://www.bifwcx.com/article/web_35344.html