Home Forums General Issues WYSIWYG Inline-Styles / text-align


WYSIWYG Inline-Styles / text-align

  • Hello Amigos,

    this is probably not a 100 % ACF issue, but still…

    i’ve been searching for this quite a while, but never found a answer, neither on stackoverflow or here:

    Is there a way to avoid inline styles in the WYSIWYG-Editor? Let’s say i use the “text-center” button in the editor, i don’t want a:

    <p style=”text-align:center”> but a <p class=”textcenter”>

    is there a way to do this without preg-replace? I was already thinking of the add_filter(‘tiny_mce_before_init’, ‘change_mce_options’) filter, but somehow this just doesn’t want to work or i’ve got the wrong approach…


  • Thanks, i found that link a while ago, but i was to stupid to use it properly…

    For anyone who might need it sometime:

    function change_mce_options($settings) {
    $new_formats = array(
    			'aligncenter' => array(
    				'selector' => 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img',
    				'classes' => 'textcenter',
    $settings['formats'] = json_encode($new_formats);
    return $settings;
    add_filter('tiny_mce_before_init', 'change_mce_options');
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘WYSIWYG Inline-Styles / text-align’ is closed to new replies.