0

構造:

    • プロジェクト
      • プロジェクトページ1
        • プロジェクト1
      • プロジェクトページ2
        • プロジェクト2
      • プロジェクトページ3
        • プロジェクト3

ページを説明順に表示するために、プロジェクトカテゴリをループしたいと思います。

私はこれまでに持っています:

<?php query_posts("posts_per_page=2&post_type=page&order=DESC&post_parent=61&exclude=168,170,166");


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

ただし、これはプロジェクト自体ではなく、プロジェクトページのみを表示しています。クエリで除外が機能しているかどうかはわかりません。

編集:

args_mergeを使用してすべての子ページを返すこれを見つけました。すべての子ページから最新の2つの投稿のみを返すように、これを変更する方法を知りたいです。

<? $args = array( 
             'child_of'    => 61,
             'sort_column' => 'post_date',
             'sort_order'  => 'desc'
        );
$child_pages = get_pages( $args );

$args['child_of'] = 166;
        $second_page_group = get_pages( $args );
        $child_pages = array_merge( $child_pages, $second_page_group );
$args['child_of'] = 168;
        $third_page_group = get_pages( $args );
        $child_pages = array_merge( $child_pages, $third_page_group );
$args['child_of'] = 170;
        $forth_page_group = get_pages( $args );
        $child_pages = array_merge( $child_pages, $forth_page_group );
unset( $second_page_group, $third_page_group, $args );

if( !empty( $child_pages ) )
foreach( $child_pages as $_my_page ) {
    $title   = apply_filters( 'the_title', $_my_page->post_title );
    //$content = apply_filters( 'the_content', $_my_page->post_content );
    //$content = str_replace( ']]>', ']]&gt;', $content );
    $link    = apply_filters( 'the_permalink', get_permalink( $_my_page->ID ) );
                ?>

ただし、これは少し過剰に見えます。3番目のブロックを追加し、https://wordpress.stackexchange.com/questions/5580/child-page-from-2-different-parent-pagesで見つかった元の投稿から少し編集しました

4

0 に答える 0