WordPress 自定义分类、标签、页面的URL伪静态格式,加.html后缀:

function custom_page_rules() {    global $wp_rewrite;    /** page页面自定义URL样式 **/ $wp_rewrite->page_structure = $wp_rewrite->root . ‘page/%pagename%.html’;    /** tag页面自定义URL样式 **/ $wp_rewrite->extra_permastructs[‘post_tag’][‘with_front’] = ;    $wp_rewrite->extra_permastructs[‘post_tag’][‘struct’] = $wp_rewrite->extra_permastructs[‘post_tag’][‘with_front’] . ‘tag/%post_tag%.html’;    /** category页面自定义URL样式 **/ $wp_rewrite->extra_permastructs[‘category’][‘with_front’] = ‘category’;    $wp_rewrite -> extra_permastructs[‘category’][‘struct’] = $wp_rewrite->extra_permastructs[‘category’][‘with_front’].’/%category%.html’;    }    add_action( ‘init’, ‘custom_page_rules’ );

修改后需要重新保存下固定链接的规则。

www.npspro.top互联侠客
软师傅 » WordPress 自定义分类、标签、页面的URL伪静态格式

最TOP的Docker,软路由,虚拟机等学习资料

立即查看 了解详情