2015-05-19 49 views
2

我想顯示多個頁面作爲一個類別的帖子頁面。WordPress的多頁面內容作爲文章

<?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); 

       ?> 
       <h2><a href="<?php echo get_page_link($page->ID); ?>"><?php echo $page->post_title; ?></a></h2> 
       <div class="entry"> 
        <?php echo $content; ?> 
        <?php echo $page->post_title; ?> 
        <?php if(has_post_thumbnail()){ ?> 
         <?php the_post_thumbnail('featured');?> 
        <?php } ?> 
       </div> 
       <?php 
       } 
      ?> 

我有這個,但是這個代碼是顯示我的每一頁的全部內容,我需要表現出像一個帖子上的「更多」鏈接和小內容。任何想法?感謝

+0

檢查'the_excerpt()'的含量少'the_permalink()'爲更多的鏈接。 – vard

回答

0

使用下面的代碼:

<?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); 

      ?> 
      <h2><a href="<?php echo get_page_link($page->ID); ?>"><?php echo $page->post_title; ?></a></h2> 
      <div class="entry"> 

       <?php echo $page->post_title; ?> 
       <a href="<?php echo get_page_link($page->ID); ?>">read more</a> 
       <?php if(has_post_thumbnail()){ ?> 
        <?php the_post_thumbnail('featured');?> 
       <?php } ?> 
      </div> 
      <?php 
      } 
     ?> 
相關問題