wordpress个别链接伪静态。
/**
*案例设定固定链接结构为数字 id.html 结构
*/
add_filter('post_type_link', 'custom_qa_link', 1, 3);
function custom_qa_link( $link, $post = 0 ){
if ( $post->post_type == 'case' ){
return home_url( 'case/' . $post->ID .'.html' );
} else {
return $link;
}
}
add_action( 'init', 'custom_qa_rewrites_init' );
function custom_qa_rewrites_init(){
add_rewrite_rule(
'case/([0-9]+)?.html$',
'index.php?post_type=case&p=$matches[1]',
'top' );
}