2014-03-26 50 views
0

我似乎无法让我的自定义元(wp_alchemy)显示与下面。剩下的工作正常,它会显示使用自定义模板的页面。WordPress的自定义元不显示

<?php // Display list of pages using the template page-landing.php 

    $product_pages_args = array(
     'meta_key' => '_wp_page_template', 
     'meta_value' => 'page-landing.php', 
     'depth' => -1, 
     'hierarchical' => 0 
    ); 

    $product_pages = get_pages($product_pages_args); 

    //$custom_metabox = get_post_meta($post->ID,'_custom_meta',TRUE); 

    echo '<table> 
      <thead> 
       <tr> 
        <td>Service name</td> 
        <td>Cost</td> 
       </tr> 
      </thead>'; 

     foreach ($product_pages as $product_page) { 

      echo ' 
      <tr> 
       <td> 
       <a href="'.get_permalink($product_page->ID).'">'.$product_page->post_title .'</a> 
       </td> 
       <td>'; ?> 
      <?php 
      $custom_metabox = get_post_meta($post->ID,'_custom_meta',TRUE);  
        echo $custom_metabox['landing-para']; 

       echo '</td> 
      </tr>'; 
     } 

    echo '</table>'; ?> 
+0

'$ product_page-> ID'!='$ post-> ID',你是否看到错误? ;) –

回答

2

您使用$product_page作为后数据,然后使用$product_page->ID代替$post->ID

$custom_metabox = get_post_meta($product_page->ID,'_custom_meta',TRUE); 
+0

我爱你!那让我把我的头发拉出来了 – leannekera