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

时间:2017-08-15 17:23:31

标签: php wordpress custom-post-type taxonomy

我需要在类别页面上显示自定义分类法thumnbail和name。我有这段代码:

<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; ?>

它只显示孩子的名字(确定)我也必须显示thumnail。我怎么能这样做?我试过很多方面   enter image description here

在front-page.php中一切正常,我看到分类学父母 - 只看:enter image description here

1 个答案:

答案 0 :(得分:0)

您需要在循环中的某个位置调用the_post_thumbnail函数来显示缩略图。你可以在函数参数中传递你想要的缩略图的大小。

请在此处查看此功能的详细信息:https://developer.wordpress.org/reference/functions/the_post_thumbnail/