我的主题中有一个可排序的公文包。我想在其中显示公文包标签图像。我发现this 此插件。但我无法很好地定制它。
因为我不想显示帖子的分类图像,所以我想在索引中显示公文包的标签图像。我想这会很清楚的screenshot 我想把这些图片称为索引中的图片,你可以从截图中看到。
以下是我的主题代码:
<?php
$query = ff_get_query_for_section();
if( !ff_archive_layout_type_test(\'portfolio\', basename(__FILE__)) ){
return false;
}
ff_require_portfolio_archive_helper_before();
$numberOfPosts = ( $query->get(\'number-of-posts\') ) ;
?>
<!-- Filter Section -->
<section <?php ff_print_section_attributes($query->get(\'section-options-sortable section-options\'), \'small-section\'); //class="small-section bg-gray-lighter"?>>
<div class="container relative">
<!-- Works Filter -->
<div class="container align-center">
<div class="works-filter mb-0">
<a href="#" class="filter active" data-filter="*"><?php $query->printText(\'trans-all\'); ?></a>
<?php
$portfolioTagsArray = array();
$portfolioTagsString = \'\';
$postCounter = 0;
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
$postCounter++;
$t = wp_get_post_terms( $post->ID, \'ff-portfolio-tag\' );
if( !empty($t) ) foreach ($t as $onePortfolioTag) {
if( !isset($portfolioTagsArray[ $onePortfolioTag->slug ]) ) {
$portfolioTagsString .= \'<a href="#" class="filter" data-filter=".tag-\'.esc_attr($onePortfolioTag->term_id).\'">\'.ff_wp_kses( $onePortfolioTag->name ).\'</a>\';
}
$portfolioTagsArray[ $onePortfolioTag->slug ] = $onePortfolioTag;
}
if( $numberOfPosts > 0 && $postCounter >= $numberOfPosts ) {
break;
}
}
}
// Escaped HTML with tags
echo $portfolioTagsString;
?>
</div>
</div>
<!-- End Works Filter -->
</div>
</section>
<!-- End Filter Section -->
<!-- Section -->
<section <?php ff_print_section_attributes($query->get(\'section-options\'), \'page-section\');//class="page-section" id="portfolio"?>>
<div class="container relative">
<!-- Works Grid -->
<ul class="works-grid work-grid-3 hover-color clearfix" id="work-grid">
<?php
$fwc = ffContainer::getInstance();
$postMeta = $fwc->getDataStorageFactory()->createDataStorageWPPostMetas();
rewind_posts();
$postCounter = 0;
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
$postCounter++;
$currentPostId = $post->ID;
require dirname(__FILE__).\'/portfolio-archive-one-post.php\';
if( $numberOfPosts > 0 && $postCounter >= $numberOfPosts ) {
break;
}
}
}
?>
</ul>
<!-- End Works Grid -->
<?php
if( $query->get(\'show-pagination\') ) {
ff_bigstream_print_pagination();
}
?>
</div>
</section>
<!-- End Section -->
<?php
ff_require_portfolio_archive_helper_after();
我试图在这个文件中添加这些代码: <?php foreach (wp_get_post_terms( $post->ID, \'ff-portfolio-tag\' ) as $cat) : ?>
<?php z_taxonomy_image($cat->term_id); ?>
<a href="<?php echo get_term_link($cat->term_id, \'ff-portfolio-tag\'); ?>"><?php echo $cat->name; ?></a>
<?php endforeach; ?>
但我没有成功。如果你能帮忙,我将不胜感激。非常感谢。