http://kotori-blog.com/wordpress/cat_customfields/
参考
■アドバンスカスタムフィールド
タクソノミータームを選び
返り値 ID
■画像登録
■コード出力
ページ 一覧出力 フォーチ
ポイントは
'taxonomy' => 'bali-tours-cat', $post_id = 'bali-tours-cat_'.$cat_id;
ポストIDにタクソノミー名アンダーバー+ID
でそのカテゴリに入力されたもののポストIDがでる
'child_of' => 0,
'parent' => '',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => '',
'taxonomy' => 'bali-tours-cat',
'pad_counts' => false
);
$categories = get_categories($args);
//$categories = get_categories('parent=0'); 親カテゴリーのみ
foreach($categories as $category) :
$cat_id = $category->cat_ID;
$post_id = 'bali-tours-cat_'.$cat_id;
$catimg = get_field('cat_img',$post_id);
$img = wp_get_attachment_image_src($catimg, 'full');
?>
<div>あ<?php echo $category->cat_name; ?></div>
<div><a href="/bali-tours-cat/<?php echo $category->category_nicename; ?>"><img src="<?php echo $img[0]; ?>" alt="<?php echo $category->cat_name; ?>" /></a></div>
<?php endforeach; ?>
カテゴリアーカイブ出だすには
<?php
$cat_id = get_queried_object()->cat_ID;
$post_id = 'category_'.$cat_id;
$catimg = get_field('cat_img',$post_id);
$img = wp_get_attachment_image_src($catimg, 'full');
?>
<div><?php single_cat_title(); ?></div>
<div><img src="<?php echo $img[0]; ?>" alt="<?php single_cat_title(); ?>" /></div>