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 your comment

 

Related Tutorials..

How to hide/remove the Block Element from the Bricks Builder

How to hide/remove the Block Element from the Bricks Builder

Don't like the new Block element in Bricks? Just copy/paste the following code into your child theme's functions.php. By the way, It's a terrible idea…
Categories:
Tags:
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:
Pro
How to Inject a Different Type of Post in Bricks Query Loop

How to Inject a Different Type of Post in Bricks Query Loop

Updated on 26 Aug 2024 A user asks: Hello, I'd like to inject a CPT post card inside of a Bricks query loop of a different CPT…
Pro
x Number of Random Bricks Query Loop Items(s) to be Shown Every x Hours

x Number of Random Bricks Query Loop Items(s) to be Shown Every x Hours

Showing how to display one random row of a Meta Box group for an hour and then output another random row.
Pro
Making a Nav Menu Item Active for Custom Post Type Single Views in WordPress

Making a Nav Menu Item Active for Custom Post Type Single Views in WordPress

Consider this scenario: CPT: project Page titled "Project" is being used to show a list/grid of all the projects rather than the CPT archive. When…
Categories:
Pro
Limit the Number of Posts in a Bricks Query Loop of Relationship Type

Limit the Number of Posts in a Bricks Query Loop of Relationship Type

Updated on 12 Dec 2023 Bricks Query Loop popup does not have a control for setting the number of posts to be output when the…
Pro
“Truncate text to these many characters” Bricks Control

“Truncate text to these many characters” Bricks Control

Bricks provides a :<number> dynamic data tag modifier that can be used to limit the amount of text by the specified number of words. Ex.:…