• Resolved bbceg

    (@bbceg)


    Is it possible to remove the inline styles that are rendered. For example:

    <style type="text/css" id="metaslider-css-38">
            #metaslider_38.flexslider .slides li {margin-right: 5px !important;}
    </style>

    This is generating an error in the W3 validator “Element style not allowed as child of element div” and I would prefer to include this in my stylesheet instead.

    I had hoped to remove or override the filter ‘metaslider_css’ but that seems to be proving difficult.

    Hope you can help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi there,

    Please see the following support document on our website regarding the validator:
    https://www.metaslider.com/documentation/how-do-i-fix-w3c-validation-errors/

    Thanks,
    Dave

    Thread Starter bbceg

    (@bbceg)

    Hi Dave,

    Thanks for the update. I had seen that post but my understanding was that it only covers the case for where the plugin’s CSS files are included, not the inline styles. I have already disabled the Print CSS option and the inline styles still show up in the body of the page.

    Any ideas?

    Hi,

    Please can you try adding this to your themes functions.php file?

    function remove_metaslider_css( $css, $settings, $slider_id ) {
    	return "";
    }
    add_filter("metaslider_css", "remove_metaslider_css", 99999, 3);

    Regards,
    Tom

    Thread Starter bbceg

    (@bbceg)

    Thanks Tom. That didn’t work unfortunately. However somewhat bizzarely, this does…

    function remove_metaslider_css() {
        return "";
    }
    add_filter("metaslider_css", "remove_metaslider_css", 20);
    
    function remove_metaslider_css_two() {
        return "";
    }
    add_filter("metaslider_css", "remove_metaslider_css_two", 11);

    Any ideas what’s going on there and whether I could reduce that to a single filter (I tried removing each and the inline styles came back so they both seem to be required). I also tried including the three expected arguments on both with the same result.

    Hi bbceg,

    I’ve asked my colleague to test the code posted, and it works for him also (as does your code – either option).

    Please can you double check everything? The code I pasted should be the “belt and braces” approach. If you are using caching plugins please make sure you clear the cache after making changes.

    Regards,
    Tom

    Thread Starter bbceg

    (@bbceg)

    Ok, thanks Tom. I think it must be some kind of conflict at my end as I also would have expected your code alone to work. I can’t explain why adding two versions of the same filter would fix the problem but I’ll start disabling plugins and go from there. I’m testing the changes in an environment without any caching applied so we can at least rule that one out.

    Thread Starter bbceg

    (@bbceg)

    Just for closure… I revisited the issue and managed to get every variant that wasn’t working above to work. Not quite sure what did it as I didn’t disable a single plugin but hopefully this thread will prove helpful for someone in the future. Thanks to the guys at Matcha Labs for the help.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Removing Inline Styles from all sliders’ is closed to new replies.