自定义分类thumnbails类别页面上的自定义帖子类型
问题描述:
我需要显示自定义分类thumnbail和名称分类页面上。我有这样的代码:自定义分类thumnbails类别页面上的自定义帖子类型
<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; ?>
这说明孩子(其确定)的唯一名字我必须表现出略图了。我怎么能做到这一点?我想在很多方面 enter image description here
在前面page.php文件一切正常,我看到父母分类 - 只要看看:enter image description here
答
你需要的地方调用the_post_thumbnail
功能在你的循环中显示的缩略图。你可以在函数参数中传递你想要的缩略图的大小。
在这里看到这个功能的细节:https://developer.wordpress.org/reference/functions/the_post_thumbnail/
我不相信我做了什么。我有缩略图的自定义分类,但在单一产品中,我没有thumnbails ...也许我需要休息。谢谢你的回答! –
如果是自定义帖子类型,则需要指定您想在帖子类型声明中使用缩略图。当你调用register_post_type函数时,你需要指定“supports”参数。请参阅文档页面上的edulcorate示例https://codex.wordpress.org/Function_Reference/register_post_type – Fabien