如何在循环投资组合页面中的内容上方显示投资组合类别

时间:2012-12-24 07:38:43

标签: wordpress themes

我想在显示所有投资组合的内容上方显示投资组合类别。我知道循环portfolio.php中需要进行一些修改,但是如何将其显示在内容帖子上方。我想以ul li格式显示它是如何可能的?我正在使用broadscope主题

我的循环portfolio.php代码如下所示

<?php 
global $avia_config;
if(isset($avia_config['new_query'])) {

    query_posts($avia_config['new_query']);
 }

// check if we got a page to display:
if (have_posts()) :


    $loop_counter = 1;
    $extraClass = 'first';

    //iterate over the posts
    while (have_posts()) : the_post();  

    //get the categories for each post and create a string that serves as classes so the javascript can sort by those classes
    $sort_classes = "";
    $item_categories = get_the_terms( $id, 'portfolio_entries' );

    if(is_object($item_categories) || is_array($item_categories))
    {
        foreach ($item_categories as $cat)
        {
            $sort_classes .= $cat->slug.'_sort ';
        }
    }


?>


        <div class='post-entry one_third all_sort <?php echo $sort_classes.$extraClass; ?>'>

            <a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php _e('Permanent Link:','avia_framework')?> <?php echo avia_inc_display_featured_within_entry('portfolio', false); ?>"><?php echo avia_inc_display_featured_within_entry('portfolio', false); ?></a>

            <a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php _e('Permanent Link:','avia_framework')?> <?php the_title(); ?>"><?php the_title(); ?></a>

            <span class='date_sort hidden'><?php the_time('Y m d H i s'); ?></span>

            <div class="entry-content">

                <!--<?php the_excerpt(); ?> -->

            <!--<a class="more-link" href="<?php echo get_permalink(); ?>"><?php _e('Read more','avia_framework'); ?></a>
            -->
            </div>                          
        <!-- end post-entry-->
        </div>

<?php 

    $loop_counter++;
    $extraClass = "";
    if($loop_counter > 3)
    {
        $loop_counter = 1;
        $extraClass = 'first';
    }


    endwhile;       
    else: 
?>  

    <div class="entry">
        <h1 class='post-title'><?php _e('Nothing Found', 'avia_framework'); ?></h1>
        <p><?php _e('Sorry, no posts matched your criteria', 'avia_framework'); ?></p>
    </div>
<?php

    endif;

?>

我希望在

之前显示投资组合类别
<a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php
_e('Permanent Link:','avia_framework')?> <?php echo avia_inc_display_featured_within_entry('portfolio', false); ?>">

里面

<div class='post-entry one_third all_sort <?php echo
$sort_classes.$extraClass; ?>'>

所以,如果有人知道,请帮助我。希望各位朋友帮助我解决这个问题

1 个答案:

答案 0 :(得分:0)

尝试插入以下代码

<?php
$post_id = get_the_ID()
$item_terms = get_the_terms( $post_id, 'portfolio_entries' );

if($item_terms !== false && count($item_terms) > 0)
{
    echo '<ul>';
    foreach ($item_terms as $term)
    {
        echo '<li>'.$term->name.'</li>';
    }
    echo '</ul>';
}
?>

之后

<div class='post-entry one_third all_sort <?php echo $sort_classes.$extraClass; ?>'>