Advanced Custom Fields Get Field from Custom Taxonomy on taxonomy.php dynamically

Yep, long title. But what we are doing here is pulling an advanced custom field that is linked to a custom taxonomy and setting it up to be dynamic on the taxonomy template page.

The example here will show you how to check for the “Alternate Title” field on a Custom Taxonomy, and if not empty to display it within the current taxonomy. If empty, show the title. The advanced Custom Field requires the registered name of the taxonomy, an underscore, and the id number of the tax.

You can always create a special template off the taxonomy.php For example, you could have a taxonomy of “eventtypes”. So you could create a page template called, “taxonomy-eventtypes.php” and within that template, you could write your title like this:

But you can get carried away with lots of different templates covering all your custom taxonomies. So how do we make it dynamic? You can do that with the queried_object and extract the term_id and the taxonomy. That way all you’d have to have is one template, “taxonomy.php” and the rest is dynamic. Example:

	$taxonomy = $wp_query->queried_object->taxonomy;