簡體   English   中英

無法在父頁面wordpress上顯示子頁面內容

[英]Can't display sub page content on parent page 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>

它應該可以工作,但是只是print_r($parent); 在while循環開始之前,檢查內容數組鍵;

否則嘗試通過$parent = get_posts($args); 而不是$parent = new WP_Query( $args );

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM