2013-03-25 11 views
10

My Wordpressのインストールには、ページ、投稿、ポートフォリオという3つの投稿タイプがあります。現在、以下のような構造がある:ページリストポートフォリオJust PostsのWordpressカスタムパーマリンク

  • example.com/post-name
    • ページ:example.com/page-name
    • ポスト一覧ページ:example.com/blog
    • 個々のポスト
    • example.com/portfolioを個々のポートフォリオ投稿: example.com/portfolio/portfolio-name

    私が変更したいのは、個々のポストパーマリンクですが、それ以外のものはありません。私はexample.com/blog/post-nameになりたいです。

    他のタイプに影響を与えずにこの変更を行う方法を示すドキュメントが見つかりません。

    EDIT: 私の現在のパーマリンク構造を/%postname%/なるように設定されている、リーディング設定の下で、私の記事のページをブログに設定されています。

    register_post_type('portfolio', array( 
    'label' => 'Portfolio Items', 
    'description' => '', 
    'public' => true, 
    'show_ui' => true, 
    'show_in_menu' => true, 
    'capability_type' => 'post', 
    'hierarchical' => true, 
    'rewrite' => array('slug' => 'portfolio'), 
    'with_front' => false, 
    'query_var' => false, 
    'has_archive' => true, 
    'exclude_from_search' => false, 
    'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes'), 
    'taxonomies' => array('category','post_tag'), 
    'labels' => array (
        'name' => 'Portfolio Items', 
        'singular_name' => 'Portfolio Item', 
        'menu_name' => 'Portfolio Items', 
        'add_new' => 'Add Portfolio Item', 
        'add_new_item' => 'Add New Portfolio Item', 
        'edit' => 'Edit', 
        'edit_item' => 'Edit Portfolio Item', 
        'new_item' => 'New Portfolio Item', 
        'view' => 'View Portfolio Item', 
        'view_item' => 'View Portfolio Item', 
        'search_items' => 'Search Portfolio Items', 
        'not_found' => 'No Portfolio Items Found', 
        'not_found_in_trash' => 'No Portfolio Items Found in Trash', 
        'parent' => 'Parent Portfolio Item', 
    ) 
    )); 
    

    答えて

    33

    は、単にあなたのパーマリンク構造として、これはあなたのページのパーマリンクを変更しません/blog/%postname%/を設定する必要があります。

    あなたのポートフォリオパーマリンクを維持するには、この投稿タイプを登録するときにwith_frontfalseに設定する必要があります。

    'with_front' => bool permastructには フロントベースを前置する必要があります。 (例:パーマリンクの構造が/blog/の場合、 のリンクは、true->/blog/news/)です。デフォルトはtrue

    EDIT 1:その後はおそらくflush Wordpress rewrite rulesになるはずです。

    EDIT 2:with_front paramがrewrite PARAMです:

    'rewrite' => array('slug' => 'portfolio', 'with_front' => false), 
    
    +0

    [OK]を、ので、これは主に働きました。ブログのリストと個々のブログページは正しいです。ポートフォリオ一覧ページと個々のページには、/ blog /が正しくありません。残りの問題は次のとおりです。 私のポートフォリオ一覧ページに移動したら、項目のタイトルの1つをクリックしてその項目のページに移動し、example.com/blog/portfolio/porfolio-itemに行きます-title example.com/portfolio/portfolio-item-titleの正しいURLに行くのではなく – frogg3862

    +0

    私の答えに記載されているように投稿タイプを正しく登録しましたか?また、Wordpressの書き換えルールをフラッシュする必要があります。 – soju

    +0

    はい、あなたはそれを記述した投稿タイプを登録しました。私は今、書き換えルールをフラッシュしました。すべてのブログページは問題ありませんが、ポートフォリオは再び/ blog/ – frogg3862

    関連する問題