Archived topic
How Do I Stop HTML From Being Stripped Out
10 replies · Started by Mary Pearson on February 27, 2018
I want a hover image on home page at https://maceducationcanada.com/ so have included the following HTML
<div class="paytostudy"><a target="_blank" href="https://paytostudy.com"><img src="https://maceducationcanada.com/eric-content//uploads/2018/02/paytostudy-min.jpg" /></a></div>
with CSS of
.paytostudy {
background-image: url("uploads/2018/02/paytostudy-min.jpg") no-repeat;
display: inline-block;
height: 140px;
width: 513px;
}
.paytostudy:hover {
background-image: url("uploads/2018/02/paytostudy-hover-min.jpg") no-repeat;
}
Unfortunately WP keeps stripping out the code. I have tried using and
tags and have added to my functions.php in the child-theme// stop wp removing div tags
function ikreativ_tiny_mce_fix( $init )
{
// html elements being stripped
$init['extended_valid_elements'] = 'div[*]';// pass back to wordpress
return $init;
}
add_filter('tiny_mce_before_init', 'ikreativ_tiny_mce_fix');Nothing seems to work.
How do I stop WP from stripping out my code so that my hover image will work?
Thanks!
Which code is it stripping out?
It got stripped out from my original post here. I'll try putting it in tags.
<div class="paytostudy"><a target="_blank" href="https://paytostudy.com"><img src="https://maceducationcanada.com/eric-content//uploads/2018/02/paytostudy-min.jpg" onmouseover="this.src='https://maceducationcanada.com/eric-content//uploads/2018/02/PaytoStudy-hover-min.jpg'" onmouseout="this.src='https://maceducationcanada.com/eric-content//uploads/2018/02/paytostudy-min.jpg'"></a></div>
Basically it removes the onmouseover this.src and on mouseout this.src URLs
Can you add the code to a pastebin and share it here?: https://pastebin.com/
This is what I would like it to be
without the extra // in front of uploads
Ah yes - WordPress will always strip that kind of stuff out, as it can be dangerous.
More info in this thread, and a function which should "fix" it: https://core.trac.wordpress.org/ticket/27858#comment:25
Thanks Tom. I had tried another functions.php code (shown in my original post), but it didn't work. Will give this new one a try. It looks like it's more inclusive.
Thanks again!
No problem :)
It works! Thanks again!
You're welcome! :)