Skip to content

Commit

Permalink
网址块伪静态
Browse files Browse the repository at this point in the history
  • Loading branch information
owen0o0 committed Dec 6, 2019
1 parent e8e0f49 commit 0d94f4a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions inc/post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function post_type_sites() {
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'site' ),
'rewrite' => array( 'slug' => 'sites' ),
'capability_type' => 'post',
'menu_icon' => 'dashicons-admin-site',
'has_archive' => false,
Expand Down Expand Up @@ -134,21 +134,21 @@ function save_term_order( $term_id ) {
*/
add_filter('post_type_link', 'custom_sites_link', 1, 3);
function custom_sites_link( $link, $post = 0 ){
if ( $post->post_type == 'site' ){
return home_url( 'site/' . $post->ID .'.html' );
if ( $post->post_type == 'sites' ){
return home_url( 'sites/' . $post->ID .'.html' );
} else {
return $link;
}
}
add_action( 'init', 'custom_sites_rewrites_init' );
function custom_sites_rewrites_init(){
add_rewrite_rule(
'site/([0-9]+)?.html$',
'index.php?post_type=site&p=$matches[1]',
'sites/([0-9]+)?.html$',
'index.php?post_type=sites&p=$matches[1]',
'top' );
add_rewrite_rule(
'site/([0-9]+)?.html/comment-page-([0-9]{1,})$',
'index.php?post_type=site&p=$matches[1]&cpage=$matches[2]',
'sites/([0-9]+)?.html/comment-page-([0-9]{1,})$',
'index.php?post_type=sites&p=$matches[1]&cpage=$matches[2]',
'top'
);
}

0 comments on commit 0d94f4a

Please sign in to comment.