フォーラムへの返信

1件の返信を表示中 - 1 - 1件目 (全1件中)
  • フォーラム: 使い方全般
    返信が含まれるトピック: カスタム投稿タイプ名にリンクを付けたい
    トピック投稿者 innis

    (@innis)

    jim912さん、こんにちは。

    gameというカスタム投稿(page-game.phpで一覧表示させています)の
    single-game.phpに教えて頂きましたコードを下記のように書きました。

    <a href="<?php echo get_post_type_archive_link( 'game' ); ?>">Game Archive</a>

    リンクは表示されたのですが、
    Game Archiveのリンク先が、page-game.phpで表示させたい一覧にならず、
    single-game.php(例えばスーパーマリオブラザーズの記事)自体にリンクが貼られてしまっています。

    表示結果:<a href="http://○○○.com/game/supermario">Game Archive</a>
    表示させたいもの: <a href="http://○○○.com/game/">Game Archive</a>

    何か他の適したコードを書かなければならないと思うのですが、google検索してみても良く分かりません。

    function.phpには以下のコードを書いてあります。

    //game
      register_post_type( 'game',
        array(
          'label' => 'GAME',
          'public' => true,
    	  'query_ver' => false,
          'menu_position' => 5,
    	  'supports' => array('title','editor','thumbnail',
          'author','revisions','page-attributes')
        )
      );
    
      register_taxonomy(
        'gamecat',
        'game',
        array(
          'label' => $labels,
          'hierarchical' => true,
    	  'rewrite' => true,
          'update_count_callback' => '_update_post_term_count',
          'singular_label' => 'GAMEのカテゴリー',
    	  'has_archive' => true,
          'public' => true,
          'show_ui' => true
        )
      );
    flush_rewrite_rules( false );

    重ね重ね申し訳ありませんが、教えて下さいますよう、どうぞ宜しくお願い致します。

1件の返信を表示中 - 1 - 1件目 (全1件中)