Output taxonomy terms as links with limit

mth
mth
11 Jun 2022
<?php
$all_tax_data = get_terms(
	array(
		'taxonomy' => 'YOUR-TAXONOMY',
		'hide_empty' => false,
		'number' => 4
	)
);

foreach($all_tax_data as $custom_term){
        $custom_term_name = $custom_term->name;
        $custom_term_link = get_term_link($custom_term->term_id);

	echo '<a href="'.$custom_term_link.'">
	'.$custom_term_name.'
	</a>';
}

Was this article helpful?

Tags

Categories

Never miss new post again

Subscribe and get list of new posts in your inbox

Click to Copy