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

找到了两个可以解决问题的简单插件。

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

于 2015-06-05T14:10:37.790 回答