The Taxonomy field allows you to select one of your WordPress taxonomies from a searchable dropdown menu.
This field type is exclusive to Block Lab Pro.

Settings
- Help Text: Instructions to describe the data needed in the field.
- Taxonomy Type: The taxonomy type filter (e.g. Categories, Tags)
PHP API Controls
- name
- label
- control
- type
- order
- location
- width
- help
- post_type_rest_slug
Template Usage
To display the Taxonomy field in your template, use the field name you provided.
<?php block_field( 'source' ); ?>
The API will return a WP_Taxonomy
object, and echo the Taxonomy’s name
. See the WP_Taxonomy class on WordPress.org.
Example template file /blocks/block-block-lab-example.php
<?php // Block Lab Example Taxonomy Field $taxonomy = block_value( 'source' ); // can be named anything, e.g., $source $terms = get_terms( $taxonomy ); foreach ($terms as $term ) { $term_link = get_term_link( $term ); if ( is_wp_error( $term_link ) ) { // just in case we encounter an error continue; } echo 'View more: <a href="' . esc_url( $term_link ) . '">' . $term->name . '</a>'; }
To use the block with the Taxonomy field on your site, locate it in the blocks menu.

It will then display within your post/page.

And then on the front-end of your site.
