カスタムの Wordpress 分類法に関連付けられたアイコンを表示する必要があります。タクソノミーのコードは次のとおりです。
$labels = array(
'name' => 'Country/State/City' ,
'singular_name' => 'Genre' ,
'search_items' => __( 'Search Country/State/City' ),
'all_items' => __( 'All Country/State/City' ),
'parent_item' => __( 'Parent Country/State/City' ),
'parent_item_colon' => __( 'Parent Genre:' ),
'edit_item' => __( 'Edit Country/State/City' ),
'update_item' => __( 'Update Country/State/City' ),
'add_new_item' => __( 'Add New Country/State/City' ),
'new_item_name' => __( 'New Country/State/City' ),
'menu_name' => __( 'Country/State/City' ), );
register_taxonomy( 'location', 'post', array( 'hierarchical' => true, 'labels' => $labels, 'query_var' => true, 'rewrite' => true ) );
}
国旗 (Spain.png、France.png など) を含むテーマ フォルダー内にフォルダーを作成しました。
横にフラグが付いた最新の投稿タイトルのリストを表示する必要があります。
そこで、ループを実行して、たとえば、投稿カテゴリから最新の 10 件の投稿を取得し、そのタイトルを表示し、その横にあるアイコンが「path-to-image-folder/taxonomy-country.png」になると考えました。
どうすればいいのかわからない... 誰か手を貸してくれませんか?
編集
だから私はこれに行きました:
<h2>Recent Posts</h2>
<ul>
<?php
$args = array( 'numberposts' => '15' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
$terms = get_the_terms( $recent->ID, 'location' );
$flagimg='<img src="'.get_bloginfo('template_directory').'/images/flags/'.$terms[0]->slug.'.png" alt="'.$terms[0]->name.'" border="0" />';
echo '<li class="country-'.$terms[0]->slug.'"><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >'.$flagimg.' '.$recent["post_title"].'</a> </li> ';
}
?>
</ul>
しかし、私が取得したimg srcリンクは次のとおりです。http://inovve.net/expoff/wp-content/themes/inovve/images/flags/.png
つまり、分類名がありません.... :/