这是添加.html
, 这涉及覆盖默认的permastructure:
function wpse_178112_permastruct_html( $post_type, $args ) {
if ( $post_type === \'product\' )
add_permastruct( $post_type, "{$args->rewrite[\'slug\']}/%$post_type%.html", $args->rewrite );
}
add_action( \'registered_post_type\', \'wpse_178112_permastruct_html\', 10, 2 );
http://codex.wordpress.org/Function_Reference/add_permastruct
对于类别:
function wpse_178112_category_permastruct_html( $taxonomy, $object_type, $args ) {
if ( $taxonomy === \'product_cat\' )
add_permastruct( $taxonomy, "{$args[\'rewrite\'][\'slug\']}/%$taxonomy%.html", $args[\'rewrite\'] );
}
add_action( \'registered_taxonomy\', \'wpse_178112_category_permastruct_html\', 10, 3 );