WordPress is changing my code
-
I know that this topic has been talked over and over with no real solution (at least as far as my googling goes), but still – when I’m trying to add code in text editor WP overwrites my code.
I know that I can disable wysiwyg editor, but since I’m not the only one managing the page this is not an option. I’m using child theme based on custimizr.
What I’m trying to do is to have a photo which on mouseover changes to naother photo. Couldn’t find a plugin, but found a code that actually works
<!–start_raw–><a href="Destination URL" target="_top" onmouseover="document.sub_but.src='https://yourdomain.com/onroll.jpg'" onmouseout="document.sub_but.src='https://yourdomain.com/normal.jpg'"> <img src='https://yourdomain.com/normal.jpg' style="width:200px; height:63px; border:0px solid #cc3300;" alt="Move your mouse over me" name="sub_but"> </a><!–end_raw–>
It works fine for the first few minutes, than WP changes it to something like (not really, but like this)
><a href="Destination URL" target="_top" <img src='https://yourdomain.com/normal.jpg' style="width:200px; height:63px; </a>
The best solution I found was putting this code into functions.php
function override_mce_options($initArray) { $opts = '*[*]'; $initArray['valid_elements'] = $opts; $initArray['extended_valid_elements'] = $opts; return $initArray; } add_filter('tiny_mce_before_init', 'override_mce_options');
and that actually worked for like an hour, but afterwards WP started to add / at the end and the code is not working anymore
<a href="MYLINK" target="_top" onmouseover="document.sub_but.src='photo1'" onmouseout="document.sub_but.src='photo2'"> <img src="photo2" style="width: 250px; height: 250px; border: 0px solid #cc3300;" />'
see the backslah ad the end? Why? Oh, and I stoped using<!–start_raw–>
cause WP can’t really handle that.Any suggestions would be really appreciated.
- The topic ‘WordPress is changing my code’ is closed to new replies.