0
我在我的主題中有一個可排序的投資組合。我想在其中顯示投資組合標籤圖片。我找到了this插件。但我無法很好地定製它。如何在Wordpress中顯示投資組合圖片?
因爲我不想顯示帖子的類別圖像,我想在索引中顯示投資組合的標籤圖像。我想這個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; ?>
但我不能全成。如果你有幫助,我會很感激。非常感謝。
我不很瞭解。我考慮你的方式做了這個修改,但它是錯誤的。 '<?PHP的foreach(the_tags($ onePortfolioTag爲$標籤):?><?PHP z_taxonomy_image($標籤 - >? TAG_ID);> name; ?>' @? HassanALi –
Katzenliebe
get_the_tags($ post_id)用這種方式你會得到結果 –
對不起,它不起作用。 – Katzenliebe