2015-06-24 56 views
1

我創建爲WordPress一個onepage主題。在我的index.php,我列出了所有頁面彼此下方:WordPress的onepage縮略圖

<?php $args = array(
'sort_order' => 'ASC', 
'sort_column' => 'menu_order', //post_title 
'hierarchical' => 1, 
'exclude' => '', 
'child_of' => 0, 
'parent' => -1, 
'exclude_tree' => '', 
'number' => '', 
'offset' => 0, 
'post_type' => 'page', 
'post_status' => 'publish' 
); 
$pages = get_pages($args); 
//start loop 
foreach ($pages as $page_data) { 
$content = apply_filters('the_content', $page_data->post_content); 
$title = $page_data->post_title; 
$slug = $page_data->post_name; 
?> 
<div id='<?php echo "$slug" ?>' class="section"> 

<div id="inner-content" class="wrap cf"> 
    <div id="main" class="m-all cf" role="main"> 
     <div class="content"> 
      <h2 class="section-title"><?php echo "$title" ?></h2> 
       <?php echo "$content" ?> 
       <?php the_post_thumbnail('full'); ?> 
     </div>    
    </div> 
</div> 

<?php } ?> 

然而,我的縮略圖顯示不出來...有沒有錯誤消息,但也沒有拇指。有任何想法嗎?

回答

1

試試這個代碼

<?php $args = array(
'sort_order' => 'ASC', 
'sort_column' => 'menu_order', //post_title 
'hierarchical' => 1, 
'exclude' => '', 
'child_of' => 0, 
'parent' => -1, 
'exclude_tree' => '', 
'number' => '', 
'offset' => 0, 
'post_type' => 'page', 
'post_status' => 'publish' 
); 
$pages = get_pages($args); 
//start loop 
foreach ($pages as $page_data) { 
$content = apply_filters('the_content', $page_data->post_content); 
$title = $page_data->post_title; 
$slug = $page_data->post_name; 
?> 
<div id='<?php echo "$slug" ?>' class="section"> 

<div id="inner-content" class="wrap cf"> 
    <div id="main" class="m-all cf" role="main"> 
     <div class="content"> 
      <h2 class="section-title"><?php echo "$title" ?></h2> 
       <?php echo "$content" ?> 
     <?php echo get_the_post_thumbnail($page_data->ID, 'thumbnail'); ?> 
     </div>    
    </div> 
</div> 
<?php } ?> 
+0

完美!那很好用!謝謝 – Irene

+0

打勾回答並關閉它;-) – sarath