wordpress カスタム投稿 ターム毎表示 ×カスタムフィールド表示

<?php
$taxonomy_name = 'タクソノミー名';
$taxonomys = get_terms($taxonomy_name);

if(!is_wp_error($taxonomys) && count($taxonomys)):
	foreach($taxonomys as $taxonomy):

		$arg = array(
			'posts_per_page' => -1,
			'post_type' => 'カスタム投稿タイプ名',
			'tax_query' => array(
				array(
					'taxonomy' => $taxonomy_name,
					'field'    => 'slug',
					'terms'    => $taxonomy->slug,
					)
				)
		);

		$tax_posts = get_posts($arg);
		if($tax_posts):
?>
		<h2><?php echo esc_html($taxonomy->name); ?></span></h2>
		<ul>
			<?php foreach($tax_posts as $tax_post): ?>
			<li><a href="<?php echo get_permalink($tax_post->ID); ?>"><?php echo esc_html($tax_post->post_title); ?></a></li>
			<?php endforeach; ?>
		</ul>
<?php	endif; endforeach; endif; ?>
PAGE TOP