Last active
August 29, 2015 14:27
-
-
Save cazuki/ba9fc6db200ba9d27168 to your computer and use it in GitHub Desktop.
WordPressのカテゴリーベースを置換して削除
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function catbase_function($link) { | |
return str_replace("/category/", "/", $link); | |
} | |
function catbase_flush_rules() { | |
global $wp_rewrite; | |
$wp_rewrite->flush_rules(); | |
} | |
function catbase_rewrite($wp_rewrite) { | |
$new_rules = array('(.+)/page/(.+)/?' => 'index.php?category_name='.$wp_rewrite->preg_index(1).'&paged='.$wp_rewrite->preg_index(2)); | |
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules; | |
} | |
add_filter('user_trailingslashit', 'catbase_function'); | |
add_action('init', 'catbase_flush_rules'); | |
add_filter('generate_rewrite_rules', 'catbase_rewrite'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment