サポート » プラグイン » Custom Post Type Permalinksで月別アーカイブがうまく行かない

  • 解決済 しろ

    (@kitaguni_ht)


    カスタムポストタイプを作成、Custom Post Type Permalinksを使用し、

    <?php wp_get_archives(array('post_type' => 'ポストタイプ名', 'type' => 'monthly')); ?>

    で、サイドバーに月別アーカイブ一覧を表示していました。
    以前は正常に表示されていたので、おそらくバージョンアップした時からだと思われますが、クリックをすると、”投稿”の一覧に飛んでしまいます。

    このカスタムポストタイプのパーマリンクは

    /%year%/%monthnum%/r-%post_id%/

    にしていました。

    一度Custom Post Type Permalinksを停止し、

    <?php
    global $my_archives_post_type;
    add_filter( 'getarchives_where', 'my_getarchives_where', 10, 2 );
    function my_getarchives_where( $where, $r ) {
      global $my_archives_post_type;
      if ( isset($r['post_type']) ) {
        $my_archives_post_type = $r['post_type'];
        $where = str_replace( '\'post\'', '\'' . $r['post_type'] . '\'', $where );
      } else {
        $my_archives_post_type = '';
      }
      return $where;
    }
    add_filter( 'get_archives_link', 'my_get_archives_link' );
    function my_get_archives_link( $link_html ) {
      global $my_archives_post_type;
      if ( '' != $my_archives_post_type )
        $add_link .= '?post_type=' . $my_archives_post_type;
    	$link_html = preg_replace("/href=\'(.+)\'\s/","href='$1".$add_link." '",$link_html);
    
      return $link_html;
    }
    ?>
    
    <ul>
    <?php wp_get_archives('type=monthly&post_type=ポストタイプ名'); ?>
    </ul>

    も、試しましたがダメでした。
    パーマリンクの空保存もしてみたのですが、変わりません。
    あまり思いつく原因が思い浮かばないのですが、何が原因かおわかりの方いらっしゃいますでしょうか?

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック投稿者 しろ

    (@kitaguni_ht)

    月別、年別アーカイブのリストのリンクだけおかしいようです。
    表示されるテキスト自体は、カスタム投稿タイプのものを拾っているようです。

    トピック投稿者 しろ

    (@kitaguni_ht)

    ◆WordPress 3.8.1
    ◆Custom Post Type Permalinks 0.9.5.3
    で、このような現象が起きていましたが、プラグイン作者さんに問い合わせたところ、すぐに対応していただきました。
    Custom Post Type Permalinks 0.9.5.4へバージョンアップしたところ無事に直りました。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック「Custom Post Type Permalinksで月別アーカイブがうまく行かない」には新たに返信することはできません。