简体   繁体   English

类别页面上的自定义帖子类型的自定义分类法

[英]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.

相关问题 具有自定义类别/分类的分页自定义帖子类型 - Pagination Custom Post Type with Custom Category/Taxonomy 为自定义帖子类型类别列表添加类“ current_page_item”(注意:该类别属于自定义分类法) - Adding class “current_page_item” for custom post type category list(note: the category is belong in custom taxonomy) 在Wordpress中显示自定义帖子类型分类的页面 - Display page of custom post type taxonomy in Wordpress 从自定义帖子类型中删除默认的“类别”分类法 - Remove default “category” taxonomy from custom post type 如何在WordPress中实现URL结构,例如“网站名称/存档页面/类别(或自定义分类法/自定义帖子类型)”? - How to achieve URL structure like “website-name/archive-page/category(or custom taxonomy)/custom-post-type” in WordPress? 获取用于查询自定义帖子类型的当前页面自定义分类法 - Get the current page custom taxonomy use to query custom post type 具有分类儿童的自定义帖子类型 - Custom post type with taxonomy children 显示自定义帖子类型类别存档页面 - Displaying custom post type category archive page 在页面模板中按类别获取自定义帖子类型 - Get custom post type by category in a page template 从当前帖子(自定义帖子类型)中获取子类别和父类别名称(自定义分类) - Get child and parent category name (custom taxonomy) from current post (custom post type)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM