我们使用过WordPress的朋友肯定是知道的,我们创建的分类目录和页面,都是直接目录名称结尾的,不像页面我们可以设置.HTML或者其他后缀的尾巴。但是,类似在ZBLOG、Typecho等程序好像是可以设置分类和页面的尾巴的,如果是WP如何设置呢?
肯定是有办法的,因为WordPress有万能的插件库。
第一、插件方法
我们看到有些网友有提到是使用插件的。比如可以分别使用 html-in-category-and-pages 和 .html on PAGES 插件来解决这个问题,但是老蒋看到目前这两个插件已经过期多年,甚至前者已经被删除。所以,暂时不考虑用插件的办法。
第二、代码方法
这里我们可以使用代码办法。
// 设置分类,页面,TAG HTML结尾 Edit By www.cnzzzj.com function custom_page_rules() { global $wp_rewrite; $wp_rewrite->page_structure = $wp_rewrite->root . 'page/%pagename%.html'; $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'; $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' );
我们可以将代码添加到 Functions.php 页面中启动功能。
注:不是所有主题都支持,请自行测试。
发表评论