0

子ページを一覧表示するカテゴリ ページのように機能するページを Wordpress で作成しようとしています。(カテゴリーページのように)。ページには抜粋がないため、カスタム フィールドを抜粋として追加したいと思います (これに関する簡単なプラグインの提案がない限り)。

いくつかの例をマージしようとしましたが、正しい最終結果が得られませんでした。

<?php if ( is_page( 777 ) ) : ?>
<?php
    $mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );

    foreach( $mypages as $page ) {      
        $content = $page->post_content;
        if ( ! $content ) // Check for empty page
            continue;

        $content = apply_filters( 'the_content', $content );
    ?>
<div class="entry-header"><h2 class="entry-title"><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h2></div>
<?
$child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID." AND post_type = 'page' ORDER BY menu_order", 'OBJECT');

if ( $child_pages ) :
    foreach ( $child_pages as $pageChild ) :
        setup_postdata( $pageChild );
        $thumbnail = get_the_post_thumbnail($pageChild->ID, 'thumbnail', array( 'class' => 'alignleft' ));
?>
        <div class="child-thumb">
          <a href="<?= get_permalink($pageChild->ID) ?>" rel="bookmark" title="<?= $pageChild->post_title ?>">
            <?= $thumbnail ?>
          </a>
        </div>

<div class="entry-summary"><?php the_excerpt(); ?></div>
<? endforeach; endif; ?>
<?php } ?>
<?php endif; ?>
4

1 に答える 1

0

このトリックを実行する 2 つの単純なプラグインが見つかりました。

https://wordpress.org/plugins/page-list/ https://wordpress.org/plugins/page-excerpt/

于 2015-06-05T14:10:37.790 に答える