Support

Account

Home Forums General Issues Removing Paragraph Tags from WYSIWYG Fields? Reply To: Removing Paragraph Tags from WYSIWYG Fields?

  • I, too, am trying to use this same method but with a get_sub_field call. I have modified Elliot’s original code but I’m unable to get the field without the wpautop happening. Any suggestions on this one?

    Here’s what I am attempting to use:

    function get_sub_field_without_wpautop($field_name) {
    
    	// Temporarily remove the filter for this get_sub_field call
    	remove_filter('acf_the_content', 'wpautop');
    
    	// Get the sub field without the wpautop filter
    	$field = get_sub_field($field_name);
    
    	// Re-establish the wpautop filter for everything
    	add_filter('acf_the_content', 'wpautop');
    
    	// Return our non-wpautop'd field
    	return $field;
    }