2012-02-16 72 views
0

我已經安裝了WordPress的插件標題爲「CMS新聞」到我的網站。WordPress的 - 自定義郵政 - 自定義字段

我創建了一個自定義文章中的兩個自定義字段,我叫「團隊」

這個頁面的代碼如下:

<div class="span16"> <!-- This is column 1 --> 

      <?php if (have_posts()) while (have_posts()) : the_post(); ?> 

      <div class="pagehead"><h2 class="title_page"><?php echo get_post_meta($post->ID, 'title_page', true);?></h2></div> 

      <div class="span6 subcontent"> 
       <?php 
         $args = array ('post_type' => 'team'); 
         $lastposts = get_posts($args); 
          foreach($lastposts as $post) : setup_postdata($post); ?> 
           <div class="teamsubhead"> 
            <h2 class="team_page"><?php the_title(); ?></h2> 
            <h3 class="job_title"><?php get_post_meta($post->ID, 'jobtitle', true); ?></h3> 
           </div> 
          <?php the_content(); ?> 
       <?php endforeach; ?>      
      </div> 

      <?php endwhile; ?> 
    </div> 

我在自定義創建自定義字段帖子被稱爲「JOBTITLE」我試圖找回從該行代碼

<h3 class="job_title"><?php get_post_meta($post->ID, 'jobtitle', true); ?></h3> 

然而,沒有任何東西可以獲得輸出。

有人可以幫助我這個。我懷疑這可能與循環有關,而我的新查詢正在一個新的循環中?

在此先感謝。

回答

1

echo試試開頭:

<?php echo get_post_meta($post->ID, 'jobtitle', true); ?>

+0

Urgh!知道這可能是多麼簡單,這讓我感到痛苦。非常感謝 – StuBlackett 2012-02-16 13:03:37