WordPressのパーマリンクのカスタマイズをご紹介します。
WordPressは動的にページが生成されますので、URLには「.html」が付きません。
が、疑似的につける方法があります。
アクションフックを使って、デフォルトのパーマリンクを上書きします。
下記をfunction.phpに記述しましょう。
1 2 3 4 5 6 7 8 9 10 11 12 |
/** * 固定ページのパーマリンクを投稿名.htmlに変更 * */ add_action( 'init', 'mytheme_init' ); if ( ! function_exists( 'mytheme_init' ) ) { function mytheme_init() { global $wp_rewrite; $wp_rewrite->use_trailing_slashes = false; $wp_rewrite->page_structure = $wp_rewrite->root . '%pagename%.html'; } } |
カスタム投稿を使っている場合には、下記のプラグインも有用です。
Custom Post Type Permalinks
コメント