これをまっすぐにさせてください:
オプション 1)
次の URL を入力します:
yoursite/wholesale/
そして、あなたがいる場合とまったく同じように見ることができる:
yoursite/products-page/wholesale/
これを実現する最も簡単な方法は、ページ「wholesale」を追加し、変更されたループを含むカスタム テンプレート ページを作成することです。
http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates
http://codex.wordpress.org/Function_Reference/query_posts
また
オプション 2)
あなたが入力したい:
yoursite/wholesale/a-product/
そして同等のものを見ることができる:
yoursite/products-page/wholesale/a-product/
これを実現したい場合は、WordPress 独自の RewriteRules の追加/変更に集中する必要があります。.htaccess の使用は避ける必要があります。WP に特定のパーマリンク構造を理解させることができるからです。
はじめに、 http://www.hongkiat.com/blog/wordpress-url-rewrite/を確認することをお勧めします。
忘れないでください: パーマリンク構造を変更するたびにSettings -> Permalinks
、[変更を保存] に移動してクリックします。そうしないと、変更が適用されない場合があります。
これが .htaccess を使用して機能するかどうかはわかりませんが、WordPress 内のルールRewriteRule
は、次の例の最初に示されているようになります。
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^wholesale/(.+)/?$ /index.php?category_name=wholesale&name=$1 [NC] # (.+) represents the title of a post with the "wholesale" category
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
使用しているときは、次add_rewrite_rule
のようになります。
add_rewrite_rule('^wholesale/([^/]*)/?','index.php?category_name=wholesale&name=matches[1]','top');
上記の例は、(.+)
/([^/]*)
が投稿を表す場合にのみ機能します。カスタム投稿タイプの場合は、そのようなカスタム投稿タイプを表す変数を追加する必要があるため、機能しません。