2012-02-16 60 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