php 在归档页面上显示自定义帖子类型的所有自定义分类
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 在归档页面上显示自定义帖子类型的所有自定义分类相关的知识,希望对你有一定的参考价值。
<?php
while ( have_posts() ) {
the_post();
the_content();
}
$terms = get_terms( 'product-categories' );
echo '<div class="flex-container">';
foreach ( $terms as $term ) {
$term_link = get_term_link( $term );
if ( is_wp_error( $term_link ) ) {
continue;
}
echo '<a href="' . esc_url( $term_link ) . '" class="flex-item">';
$categoryImage = get_field( 'category_image', $term );
if ( $categoryImage ) {
echo '<img src="' . $categoryImage['url'] . '" alt="' . $term->name . '">';
}
else {
echo '<img src="' . get_template_directory_uri() . '/img/template/category-placeholder.png" alt="' . $term->name . '">';
}
echo '<div class="overlay"><div class="caption"><h3>' . $term->name . '<h3></div><span class="btn white-outline">Explore more</span></div></a>';
}
echo '</div>';
?>
以上是关于php 在归档页面上显示自定义帖子类型的所有自定义分类的主要内容,如果未能解决你的问题,请参考以下文章