0

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

我的循环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; ?>'>

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

4

1 回答 1

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; ?>'>
于 2012-12-24T18:14:25.140 回答