2017-08-15 202 views
0

我需要顯示自定義分類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

回答

0

你需要的地方調用the_post_thumbnail功能在你的循環中顯示的縮略圖。你可以在函數參數中傳遞你想要的縮略圖的大小。

在這裏看到這個功能的細節:https://developer.wordpress.org/reference/functions/the_post_thumbnail/

+0

我不相信我做了什麼。我有縮略圖的自定義分類,但在單一產品中,我沒有thumnbails ...也許我需要休息。謝謝你的回答! –

+0

如果是自定義帖子類型,則需要指定您想在帖子類型聲明中使用縮略圖。當你調用register_post_type函數時,你需要指定「supports」參數。請參閱文檔頁面上的edulcorate示例https://codex.wordpress.org/Function_Reference/register_post_type – Fabien

相關問題