Home Forums Add-ons Repeater Field Need to remove tag from one of two wysiwyg fields


Need to remove tag from one of two wysiwyg fields

  • I have a Repeater field (name “content_repetar”) which is located under options.

    There are two wysiwyg fields under this repeater field, name as below:


    The wysiwyg field is generating <p> tags automatically. But I want to remove the <p> tag from the filed “content_1” but keep <p> tag for the filed “content_1” and other wysiwyg fields.

    How can I do that?

  • ACF automatically runs a number of filters on the content and does not have any way to avoid this for only a single WYSIWYG field. The only way to do this would be to get the value unformatted

    get_field('wysiwyg_field_name', false, false);
    // or 
    get_sub_field('wysiwyg_field_name', false);

    and then apply each of the filters yourself in the correct order with the exception of ‘wpautop’

    From ACF code

    		function add_filters() {
    			// WordPress 5.5 introduced new function for applying image tags.
    			$wp_filter_content_tags = function_exists( 'wp_filter_content_tags' ) ? 'wp_filter_content_tags' : 'wp_make_content_images_responsive';
    			// Mimic filters added to "the_content" in "wp-includes/default-filters.php".
    			add_filter( 'acf_the_content', 'capital_P_dangit', 11 );
    			// add_filter( 'acf_the_content', 'do_blocks', 9 ); Not yet supported.
    			add_filter( 'acf_the_content', 'wptexturize' );
    			add_filter( 'acf_the_content', 'convert_smilies', 20 );
    			add_filter( 'acf_the_content', 'wpautop' );
    			add_filter( 'acf_the_content', 'shortcode_unautop' );
    			// add_filter( 'acf_the_content', 'prepend_attachment' ); Causes double image on attachment page.
    			add_filter( 'acf_the_content', $wp_filter_content_tags );
    			add_filter( 'acf_the_content', 'do_shortcode', 11 );
    			// Mimic filters added to "the_content" in "wp-includes/class-wp-embed.php"
    			if ( isset( $GLOBALS['wp_embed'] ) ) {
    				add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'run_shortcode' ), 8 );
    				add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 );
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.