Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
eric.philipson

ACF wysiwyg field render html

Hi
In one of my columns I’m displaying a ACF Wysiwyg Editor field. Is it possible to show the formatted HTML instead of the stripped text? The basis ones-ul,li,a-would suffice.

Thx!

5 years, 11 months ago
Stefan van den Dungen Gronovius
Developer

Hi Eric,

We do not output the HTML markup by default, because this can give unexpected behavior in the table cells.
If you want to display the HTML in your columns, you could use the following filter to alter the value for your WYSIWYG fields.

https://www.admincolumns.com/documentation/filter-reference/ac-column-value/

The following snippet will display the raw HTML for every ACF WYSIWYG field.

/**
 * @param string    $value
 * @param int       $id
 * @param AC_Column $column
 */
function acp_column_value_acf_wysiwyg( $value, $id, $column ) {
	if ( ! $column instanceof ACA_ACF_Column ) {
		return $value;
	}

	if ( 'wysiwyg' === $column->get_acf_field_option( 'type' ) ) {
		$value = get_field( $column->get_field_hash(), $id );
	}

	return $value;
}

add_filter( 'ac/column/value', 'acp_column_value_acf_wysiwyg', 10, 3 );
5 years, 11 months ago

You must be logged in to reply to this topic.