I want to set a special styling for the ul tags created by Tinymce only, which means only for posts and pages, I only found this filter tiny_mce_before_init with an example on how to add custom style options to an existing style dropdown.
so is there a way to add a class to ul tags created by the WordPress editor ?
It’s always a good idea to look at WordPress Codex before asking. TinyMCE Custom Styles
In editor: first create an unnumbered list, then apply the style.
Update after acceptance.
If you want to append a class to all
<ul>
elements added through TinyMCE you can do it prior to inserting into or updating the database:Tune
str_replace()
functionneedle
if<ul>
elements already has any attributes. Or usepreg_replace()
there.Is that really necessary? Try to modify you theme’s page.php and single.php in a way it’s wrapp the_content(); template tag with a div of specified class or id. This way:
And use that id in your stylesheet:
This might be enaught in most cases. Adding posibility to add custom class to UL would demand to write a tinyMCE plugin and still, you would have to click extra button to set style every time you’re creating a post/page.