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’ );
修改后需要重新保存下固定链接的规则。
原文链接:http://demo.mobantu.com/modown/blog/1000,转载请注明出处。
评论1