[英]Custom taxonomy thumnbails for custom post type on category page
I need display the custom taxonomy thumnbail and name on category page. 我需要在类别页面上显示自定义分类法缩略图和名称。 I have this code : 我有这个代码:
<h1><?php single_cat_title(); ?></h1>
<?php
$taxonomy = 'kategorie_goralskie';
$terms = get_terms($taxonomy, array('parent' => 0, 'orderby' =>
'meta_value', 'order' => 'DESC') ); // Get all top level terms of a
taxonomy
if ( $terms && !is_wp_error( $terms ) ) :
?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="col-md-3">
<a href="<?php the_permalink(); ?>"><?php the_title();?></a>
</div>
<?php endwhile; ?>
<?php endif; ?>
It shows only name of child (its ok) I must show thumnail too. 它只显示孩子的名字(可以),我也必须显示缩略图。 How i can do it ? 我该怎么办? I tried in many ways enter image description here 我尝试了多种方式在此处输入图片描述
In front-page.php everything is ok, i see taxonomy parent - just look : enter image description here 在front-page.php中,一切正常,我看到了分类父类-只需看一下: 在此处输入图片描述
You need to call the_post_thumbnail
function somewhere in your loop to display thumbnail. 您需要在循环中的某处调用the_post_thumbnail
函数以显示缩略图。 you can pass the size of the thumbnail you whant in function parameter. 您可以在功能参数中传递您想要的缩略图的大小。
See the detail of this function here : https://developer.wordpress.org/reference/functions/the_post_thumbnail/ 请在此处查看此功能的详细信息: https : //developer.wordpress.org/reference/functions/the_post_thumbnail/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.