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

如果有人可以提供帮助,那就太好了!如果需要更多信息,请告诉我。

4

1 回答 1

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

于 2011-07-29T16:53:53.823 回答