2011-07-29 152 views
0

我已经搜索了很多这个问题,但我找到的是如何显示特定分类标准的每个类别的答案。在自定义帖子列表中显示帖子的分类

我正在开发一个主题,我将使用jQuery过滤一个帖子列表(自定义帖子类型'作业'),但我需要有一个<div>,并显示该帖子的类别。

我将在类别页面(作业)上过滤这些内容。

为了这个工作,我把我所有的代码放在loop.php中。

<div class="post_entry"> 
     <div class="post-thumb"><?php the_post_thumbnail('single-post-thumbnail'); ?></div> 
     <h4 class="post-title"><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr__('%s', 'twentyten'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></h4> 
     <?php 
      $location = get_post_meta($post->ID, 'location', TRUE); 
      $organization = get_post_meta($post->ID, 'organization', TRUE); 
      $url = get_post_meta($post->ID, 'url', TRUE); 
     ?> 
     <div class="post-meta"> 
      <?php if($organization != ''){ ?><p class="post_meta_organization"><?php echo $organization; ?></p><?php } ?> 
      <?php if($location != ''){ ?><p class="post_meta_location"><?php echo $location; ?></p><?php } ?> 
      <?php if($url != ''){ ?><p class="post_meta_url">Website: <a href="<?php echo $url; ?>">Click Here</a></p><?php } ?> 
     </div> 
     <div class="hidden tags"> 

     </div> 


<?php if (is_archive() || is_search()) : // Only display excerpts for archives and search. ?> 
     <p class="post_excerpt"><?php the_excerpt(); ?></p> 
<?php else : ?> 
     <div class="category_read_more"><?php the_content(__('Read More', 'twentyten')); ?></div> 
     <?php wp_link_pages(array('before' => '' . __('Pages:', 'twentyten'), 'after' => '')); ?> 
<?php endif; ?> 
      <?php edit_post_link(__('Edit', 'twentyten'), '', ''); ?> 

    <?php comments_template('', true); ?> 
    </div> 

我很幸运加元框的信息,但我想显示自定义的职位类别(jobtype)在<div class="hidden tags"></div>

要看看网页,看看http://www.cirkut.net/wp/libertyguide/jobs

如果有人可以帮忙,那太棒了!如果需要更多信息,请告诉我。

回答

0

在循环:

Category: <?php echo get_the_category_list(', '); ?> 

更新:

的WordPress写道:

清单条款

如果你想在你的主题自定义列表,然后您可以将 分类名称传递到循环中的the_terms()函数中,如下所示:

the_terms($ post-> ID,'people','People:',',','');

这应该解决您的问题。

http://codex.wordpress.org/Taxonomies#Listing_the_terms

+0

这是行不通的。我正在使用自定义分类。为了澄清一点,我需要在空格分隔的列表中显示类别(例如'web-dev职业全职'而不是'web/dev,职业,全职) –

+0

我已经更新了答案。现在希望你在找什么。 –

相关问题