7th Nov '22
/
4 comments

Post Terms Separator in Bricks

When post_terms_<taxonomy> dynamic data tag is used in Bricks in an element like the “Meta Data”, the linked terms are separated by commas by default.

Note: The Separator control you see in the above screenshot is not for the individual terms, but rather the items of that element.

If you would like these to be replaced with another like | or spaces or remove them completely, we can use the bricks/dynamic_data/post_terms_separator filter like this:

add_filter( 'bricks/dynamic_data/post_terms_separator', function( $sep, $post, $taxonomy ) {
	return ' | ';
}, 10, 3 );

To remove the separator(s):

add_filter( 'bricks/dynamic_data/post_terms_separator', function( $sep, $post, $taxonomy ) {
	return '';
}, 10, 3 );

If you would like to limit to specific taxonomies:

add_filter( 'bricks/dynamic_data/post_terms_separator', function( $sep, $post, $taxonomy ) {
	if ( $taxonomy === 'testimonial_type' ) {
		return '';
	}

	return $sep;
}, 10, 3 );

where testimonial_type is the name of the taxonomy.

Get access to all 627 Bricks code tutorials with BricksLabs Pro

4 comments

  • Stephen Walker

    The ability to use a delimiter parameter in the dynamic data would be a really nice add-on for any time you are using a taxonomy {my-term:'my-delimeter':plain)

  • Álvaro Massana de Castro

    In parent terms it creates a separation with a "-" of some sort. How could we change the separator for parent terms? It would be great if it could be like: term1 (subterm1, subterm2, subterm3), term2 term1 (subterm1, subterm2, subterm3), etc. Thank you,

  • Niels Tieman

    Would this work on relationships as well? Currently they are shown as a list.

Leave your comment

 

Related Tutorials..

How to Exclude Elements from Bricks Editor

How to Exclude Elements from Bricks Editor

Bricks has a handy bricks/builder/elements filter using which the available elements that show up after clicking + (or ⌃/⌘ + ⇧ + E) in the…
Categories:
Tags:
Pro
Programmatically populating ACF field values in WordPress

Programmatically populating ACF field values in WordPress

An example of how to set the values of a Select-type field with the names and labels of all public post types.
Categories:
How to Remove Name and Website Fields in Bricks Comment Forms

How to Remove Name and Website Fields in Bricks Comment Forms

Updated on 14 Mar 2024 In the BricksLabs Facebook group a user asked: What is the best method to remove fields from the Bricks "Comments"…
How to create filters with IsotopeJS in Bricks (Part 1)

How to create filters with IsotopeJS in Bricks (Part 1)

This tutorial series will explore the IsotopeJS library's features inside the Bricks ecosystem.
Categories: