2021-01-15 07:13:06

Related Docs

You have seen all Documentation regarding .
Search the complete TukuToi Software Documentation!

Do You Need Help or Expertise?

Is editing Source Code not Your Thing? Are you in a tight Time Schedule and need to deliver a fully scalable and safe solution fast to your Clients?

Maybe you want to incorporate the Software found on TukuToi unbranded and royalty free in your Clients Projects after customizing it as per your Projects requirements?

Or eventually you need some training on any WordPress Plugin, Theme or their creation and maintenance?

FilterModify WP Grid Builder Facet HTML – add a title tag

Custom Code to customise WP Grid Builder Facet HTML

In this filter we have access to the WP Grid Builder Facet HTML. It allows to perform simple str_replace() operations, or more complex actions, for example, adding a title tag to each facet, so on hover of the facet we can see the current Facet Option data

In this example, it is a Taxonomy facet and we want to display the description of the term as a title.

The Taxonomy is “Our Custom Taxonomy” and facet ID is 2 in the example.

We use the helper function tkt_get_contents to get the several occurrences of the strings to replace.

add_filter( 'wp_grid_builder/facet/html', 'tkt_facet_html', 10, 2 );

function tkt_facet_html( $html, $facet_id ) {

	$taxonomy 	= 'our-custom-taxonomy-slug';
	$start		= '';//if checkbox, analyse HTML to be sure
	$end 		= ' ';//Usually there is a empty space at the end of label, check HTML to be sure

	if ( 2 === (int)$facet_id ) {
		$term_names 	= tkt_get_contents($html, $start, $end);

		foreach($term_names as $term_name){
			$term   	= get_term_by( 'name', $term_name, $taxonomy);
			$term_desc 	= trim( strip_tags ( term_description( $term->term_id ) ) );
			$html 	   	= str_replace( $start . $term_name . $end, '' . $term_name . $end, $html );
	return $html;