Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Category Terms ID and Names

Return only Category Terms “ID” and “Names” for better performance.

// WP_Term_Query arguments
$args = array (
	'taxonomy'               => array( 'category' ),
	'fields'                 => 'id=>name',
	'hide_empty'             => true,
);

// The Term Query
$term_query = new WP_Term_Query( $args );