1. Home
  2. Docs
  3. Divi Query Builder
  4. Action & Filter Hook...
  5. Custom Field HTML Output

Custom Field HTML Output

Overview

The ctdqb_custom_field_html  filter hook allows you to modify custom fields HTML output.

Hook Parameters

  1. $html: The original HTML content of the custom field.
  2. $module_props: An array containing module-specific properties.
  3. $custom_field: An array containing custom field data.
  4. $post_data: An array containing current post/term/user data.

https://gist.github.com/divicoding-dev/498302f687c64c635f6a144fc6e52d27

function ctdqb_custom_field_html_filter( $html, $module_props, $custom_field, $post_data ) {
	// Use the admin label if you need to apply the filter only to a specific module
	if ( isset( $module_props['admin_label'] ) && $module_props['admin_label'] === 'change_custom_field_output' && $custom_field['name'] === 'acf_date_picker' ) {
		if ( isset( $custom_field['raw_value'][0] ) ) {
			$date = new DateTime( $custom_field['raw_value'][0] );
			$html = 'DATE: ' . date_format( $date, 'Y-m-d H:i:s' );
		}
	}

	return $html;
}

add_filter( 'ctdqb_custom_field_html', 'ctdqb_custom_field_html_filter', 10, 4 );

https://gist.github.com/divicoding-dev/185797c6e68784300bdd2482510845a1

0 Comments

Submit a Comment

How can we help?