简体   繁体   中英

Can't display sub page content on parent page wordpress

I have a single page that contains links to child pages. So far I have been able to get the the title and featured image for each child page but I can't get the main content to display, it is just showing blank what ever I do. I also have a filter, which filters based on the categories used for the child pages.

This is what I have at the moment:

    <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>

It should work but Just print_r($parent); before while loop starts and check content array key;

otherwise try to get through $parent = get_posts($args); instead of $parent = new WP_Query( $args );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM