2012-02-01 7 views
1

私は適切に動作している '編集者'のカスタム投稿タイプを持っています。親の場合は.... ElseIf Child Show ...同じページに?

各投稿タイプには、メインエディタの親のさまざまな子投稿があります。私はその親ならば、それはXのコンテンツを表示するには、しかし、その子は完全に異なるコンテンツを表示する場合は、明らか任意の親コンテンツを無視する必要があるシングルeditors.phpページ

...

これは何ですその可能な場合ので、私は疑問に思う私は条件文では良いよん

<?php get_header(); ?> 

<!-- IF Parent Show Below --> 

<?php $this_page_id=$wp_query->post->ID; ?> 

<?php query_posts(array('showposts' => 1, 'post_parent' => $this_page_id, 'post_type' => 'editors')); while (have_posts()) { the_post(); ?> 


<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> 


<?php } ?> 

<!-- IF Child Show Below ignore the above --> 

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

<section role="document"> 

<?php the_content(); ?> 

</section> 

<?php endwhile; endif; ?> 


<?php get_footer(); ?> 

...親ページのコンテンツを示しているが、その後、子ページには何も示していない今のところ、それに関して「働く」を持ちます。 ..?当然のようにカスタムポストのすべてのコンテンツは、あなたがparent-のような2つの以上のレベルを(持っている場合は任意の助け

感謝:)

答えて

0
if ($post->post_parent == 0) { 
    // has no parent, is parent 
    get_template_part('single-editors', 'parent'); 
    } else { 
    // child 
    get_template_part('single-editors', 'children'); 
    } 

が動作しませんシングルeditors.phpに表示しています>子供 - >子供)。

+0

これは動作していないようです:( は、テンプレートだけを表示するように思わシングルエディタ-children.phpかどうか、あなたの親ページまたは子ページ..?の の任意のアイデア、見ているのに感謝:) – Jezthomp

+0

私はこれもうまくいくわけではない。これは理想的な解決策になります。 – user1167442

関連する問題