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 610 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 a Reply to Sridhar Katakam (Cancel Reply)

 

Related Tutorials..

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:
Filtering Breadcrumbs in Bricks

Filtering Breadcrumbs in Bricks

Using the bricks/breadcrumbs/items filter to modify Bricks' breadcrumbs’ element programmatically.
Categories:
Pro
Setting a Bricks template for Parent pages

Setting a Bricks template for Parent pages

This Pro tutorial shows how bricks/active_templates filter can be used to programmatically assign a Bricks template to all singular pages (of any post type) that…
How to create filters with IsotopeJS in Bricks (Part 4): AJAX filter and infinite loops, Sorting, List view and Disable animations

How to create filters with IsotopeJS in Bricks (Part 4): AJAX filter and infinite loops, Sorting, List view and Disable animations

This tutorial will explain how to enable the AJAX filter with an infinite scroll query loop container, how to add a sorting function, how to…
Categories:
Show Product Categories Count Using Bricks Filter Hook

Show Product Categories Count Using Bricks Filter Hook

Unable to find terms count from the Dynamic Data provided by Bricks theme? It's okay, this simple tutorial shows you how to properly get the…
Categories:
Tags: