无法在父页面wordpress上显示子页面内容

时间:2017-08-19 15:40:55

标签: php wordpress

我有一个包含子页面链接的页面。到目前为止,我已经能够获得每个子页面的标题和特色图像,但我无法显示主要内容,它只是显示空白我做了什么。我还有一个过滤器,它根据用于子页面的类别进行过滤。

这就是我现在所拥有的:

    <div id="people" class="relative z-level--2">
      <?php
$args = array(
      'post_type'      => 'page',
      'posts_per_page' => -1,
      'post_parent'    => $post->ID,
      'order'          => 'ASC',
      'orderby'        => 'menu_order'
   );


  $parent = new WP_Query( $args );

  if ( $parent->have_posts() ) : ?>

  <?php while ( $parent->have_posts() ) : $parent->the_post(); ?>
    <article class="
    <?php

    $terms = get_the_category( $page->ID );
      foreach ($terms as $term) :
        echo $term->slug;
      endforeach;
    ?>
    player-card inline-block pl--m pr--s gb--l vertical-top">

      <div class="player-card__container transition--xfast shadow shadow--hover">
        <a id="playerCardLink" href="<?php the_permalink(); ?>" class="player-card__link">
          <div class="p--m br--s bg--light">

              <div class="player-card__content relative br--s overflow--hidden gb--m">


                  <div class="player-card__img absolute t0 l0 b0 r0 z-level--2" style="background-image: url('<?php echo get_the_post_thumbnail_url($page->ID); ?>');"></div>
                  <div class="player-card__video relative">
                    <video class="absolute width--full height--full t0 r0 " autoplay muted playsinline loop poster="<?php echo get_the_post_thumbnail_url($page->ID); ?>">

                      <?php $file = get_field('playervideo', $page->ID);
                      $url = $file['url'];

                      ?>
                      <source src="<?php echo $url; ?>" type="video/mp4;">
                    </video>
                  </div>
                </div>
              <div class="player-card__info">
                <h3 class="uppercase fs--xl"><?php the_title_attribute(); ?></h3>
                <span class="strip strip--card gb--m"></span>

                <p class="player-card__text line-overflow--three">
                  <?php the_content() ?>

                </p>
              </div>

            </div>
          </a>


    </div>
  </article>
  <?php endwhile; ?>



<?php endif; ?>
</div>

1 个答案:

答案 0 :(得分:0)

它应该可以正常工作,但在while循环启动之前只需print_r($parent);并检查内容数组键;

否则尝试通过$parent = get_posts($args);代替$parent = new WP_Query( $args );