Site logo

[Resolved] How Do I Stop HTML From Being Stripped Out

Home Forums Support [Resolved] How Do I Stop HTML From Being Stripped Out

Home Forums Support How Do I Stop HTML From Being Stripped Out

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #507382
    Mary Pearson

    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!

    #507522
    Tom
    Lead Developer
    Lead Developer

    Which code is it stripping out?

    #507970
    Mary Pearson

    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

    #508161
    Tom
    Lead Developer
    Lead Developer

    Can you add the code to a pastebin and share it here?: https://pastebin.com/

    #508162
    Mary Pearson

    This is what I would like it to be

    https://pastebin.com/xCPb75H5

    #508168
    Mary Pearson

    without the extra // in front of uploads

    #508527
    Tom
    Lead Developer
    Lead Developer

    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

    #508980
    Mary Pearson

    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!

    #509361
    Tom
    Lead Developer
    Lead Developer

    No problem 🙂

    #509777
    Mary Pearson

    It works! Thanks again!

    #509894
    Tom
    Lead Developer
    Lead Developer

    You’re welcome! 🙂

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.