2016-03-29 11 views
0
私はカスタムポストタイプのテンプレートを作成しよう

のためのテンプレートを作成しますので、私はポストタイプを登録次のコードを入力してください:カスタムポストタイプ

echo "this is single agency page"; 

しかし、代理店の投稿を表示しようとすると、404ページが表示されます。アーカイブページでも同じことが起こります。私はここで間違って何をやっている

get_header(); 
$show_sidebar = get_post_meta($post->ID, 'show_sidebar_checkbox', true); 
if ($show_sidebar == 'yes'): 
    $bootstrap_sidebar_dep = 'col-sm-8'; 
else: 
    $bootstrap_sidebar_dep = 'col-sm-12'; 
endif; 
?> 
<div class="container"> 
    <div class="row"> 
    <div id="primary" class="content-area <?php echo apply_filters('primary_bootstrap_class', $bootstrap_sidebar_dep); ?>"> 

     <div id="content-top-wa" class="widget-area"> 
     <?php dynamic_sidebar('content-top') ?> 
     </div><!-- #content-top-wa --> 

     <main id="main" class="site-main" role="main"> 

     <?php while (have_posts()) : the_post(); ?> 

      <?php get_template_part('content', 'single'); ?> 

      <?php faster_post_nav(); ?> 

      <?php 
       // If comments are open or we have at least one comment, load up the comment template 
       if (comments_open() || '0' != get_comments_number()) : 
        comments_template(); 
       endif; 
      ?> 

     <?php endwhile; // end of the loop. ?> 

     </main><!-- #main --> 

     <div id="content-bottom-wa" class="widget-area"> 
     <?php dynamic_sidebar('content-bottom') ?> 
     </div><!-- #content-bottom-wa --> 

    </div><!-- #primary --> 
<?php 
    if ($show_sidebar == 'yes'): 
     get_sidebar();  
    endif; 
?> 
    </div><!-- .row --> 
</div><!-- .container --> 
<?php get_footer(); ?> 

: は、ここで私は、親テーマを継承私のsingle.phpコードを、ありますか?

助けてくださいありがとう!

答えて

1

あなたは再調査が必要ですパーマリンク、here's how to do it

+0

それは魅力的なように機能しました!ありがとう – Avishay28

0

これを試してください:あなたが追加したいよう

は、あなたの新しいポストタイプの新しいWP_Queryを作成します。

// Args for your Post Type: 
$args = array (
    'post_type' => array('aran_agencies'), 
); 

// The New Query 
$agencies = new WP_Query($args); 

を次にあなたは置き換えることができます:

while (have_posts()) : the_post(); 

while ($agencies->have_posts()) : $agencies->the_post(); 
関連する問題