1. Home
  2. Docs
  3. Divi ACF Object Loop
  4. Action & Filter Hook...
  5. Item HTML Output

Item HTML Output

Overview

The ctaol_item_html  filter hook allows you to modify the HTML content of items in the grid. This filter can be combined with the ctaol_get_post_data filter hook to add extra data to the items grid.

Hook Parameters

  1. $content: The original HTML content of the item.
  2. $module_props: An array containing module-specific properties.
  3. $sections: An array containing HTML sections for different parts of the item.
  4. $post_data: An array containing post data associated with the item
function ctaol_item_html_filter( $content, $module_props, $sections, $post_data ) {
	// Use the admin label if you need to apply the filter only to a specific module
	$custom_content = '';
	if ( isset( $module_props['admin_label'] ) && $module_props['admin_label'] === 'request_extra_data' && ! empty( $post_data['custom_data'] ) ) {
		$custom_content = sprintf( '<div class="ctaol-extra-data-container"><strong>ACF Text: </strong>%1$s</div>', $post_data['custom_data'] );
	}

	return $sections['image'] . $sections['title'] . $custom_content . $sections['excerpt'] . $sections['link'];
}

add_filter( 'ctaol_item_html', 'ctaol_item_html_filter', 10, 4 );

0 Comments

Submit a Comment

How can we help?