Weblog

親ページ[固定ページ]に子一覧を表示

固定ページの親ページに子の内容を表示

<?php
$child_posts = get_posts('numberposts=-1&order=ASC&orderby=menu_order&post_type=page&post_parent='.親ID );

$child_posts = get_posts('numberposts=-1&order=ASC&orderby=menu_order&meta_key=キー&meta_value=値&post_type=page&post_parent='.親ID );

if ( $child_posts ):
  foreach ( $child_posts as $child ) :
    $c_title = apply_filters( 'the_title', $child->post_title );
    $c_content = get_extended( $child->post_content );
    $c_content = apply_filters( 'the_content', $c_content['main'] );
    $c_url = $child->guid;
    //$thumb = get_the_post_thumbnail( $child->ID, array(300,300) );
?>
<div class="inner">
  <p class="thumbnail"><a href="<?php echo $c_url; ?>"><?php if($thumb) { echo $thumb; } else { echo 'no image'; } ?></a></p>
  <div class="ex">
  <h2><a href="<?php echo $c_url; ?>"><?php echo $c_title; ?></a></h2>
  <?php // ↓抜粋を表示の時はコメントタグを削除
         // 文字数の指定$count = 100;
         //$excerpt = mb_substr($c_content, 0, $count);
         //if( mb_strlen($c_content) > $count ){ echo $excerpt, '[...]</p>'; } else { echo $c_content; }
  ?>
  </div>
</div><!--inner-->
<?php
endforeach;
endif;
wp_reset_postdata();
?>