WordPress修改自定义文章类型的固定链接为 post_type/post_id.html
本例的自定义文章类型名称为book 1234567891011121314151617181920212223/** * 注册rewrite rule */ add_action( 'init', 'wpapp_custom_book_rewrites_init' ); function wpapp_custom_book_rewrites_init(){ add_rewrite_rule( 'book/([0-9]+)?.html$', 'index.php?post_type=book&p=$matches[1]', 'top' ); } /** * 修改链接格式 */ add_filter('post_type_link', 'sola_custom_book_link', 1, 3); function sola_custom_book_link( $link, $post ){ if ( $post->post_type == 'book' ){ […] (more...)