Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WordPress Editor removing div attributes

I am helping out with a wordpress site for an upcoming marine conference. One of the things I am working on is for an interactive platform page. It uses a combination of css & javascript. I am noticing for each of the div tags I am putting in, it keeps on removing some of the attributes. For example...

I put in:

<div id="booth107"
          class="booth booth_20x10bronze"
          data-name="Fluval"
          data-link="http://www.fluvalaquatics.com/"
          data-logo="http://piscespets.com/wp-content/uploads/fluval-logo.jpg"
>&nbsp;</div>

and it comes out:

<div id="booth107" class="booth booth_20x10bronze">&nbsp;</div>

I am editing in text mode, not visual, and I am not flipping back and forth.

Anyone know why I might be losing some of my div attributes?

like image 570
Navnish Bhardwaj Avatar asked Jul 23 '26 04:07

Navnish Bhardwaj


1 Answers

Try to add this code in your functions.php to override the messing up html code.

function override_tinymce_option($initArray) {
    $opts = '*[*]';
    $initArray['valid_elements'] = $opts;
    $initArray['extended_valid_elements'] = $opts;
    return $initArray;
}
add_filter('tiny_mce_before_init', 'override_tinymce_option');
like image 143
Ram Sharma Avatar answered Jul 25 '26 17:07

Ram Sharma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!