How to use new add_editor_style() function (5 posts)

  1. zeckdude
    Posted 5 years ago #

    I found this article:


    I created a child theme using the Twentyten theme as a parent. I am trying to have the WYSIWYG editor use a custom stylesheet.

    I added this to my functions.php file:

    Then I created an editor-style.css file in my child theme's folder and added this:

    html .mceContentBody {

    When I go to the WYSIWYG editor and use firebug to check the css that is affecting the .mceContentBody element, I can see that is using my stylesheet, but it is being overrriden by the default editor-style.css sheet from the twentyten theme.

    How can I force it to use my editor-style.css file and not the default one?

  2. Alexandre Simard
    Posted 5 years ago #

    Here's what I found:

    If your child theme calls add_editor_style(); without any parameter, both 'editor-style.css' stylesheets (from Twenty Ten and from your child theme) will be linked in the TinyMCE iframe, even if add_editor_style() is not called in Twenty Ten's function php. Furthermore, Twenty Ten's editor-style.css will be linked after the child theme's. Therefore, if you use identical selectors, Twenty Ten's rules will override the child's.

    I believe this is a bug. Expected behaviour should be, in order of preference:

    1. Only the child theme's editor-style.css is linked
    2. Both are linked, but the child theme's is linked after the parent theme's

    I will submit this bug and try to file a patch, but in the meantime, I've found a workaround: name your child theme's stylesheet anything else than the default 'editor-style.css' and use that name as a parameter to the add_editor_style() call in your functions.php.

  3. morgannunan
    Posted 5 years ago #

    brocheafoin, I tried your method, naming my child editor style child-editor-style.css and the parent still loaded after it. I tried calling it in both the parent and child functions.php and the parent loaded afterward. Are you getting these in the correct order with your method?

  4. MK Safi
    Posted 5 years ago #

    Workaround specified doesn't work around.

  5. Alexandre Simard
    Posted 4 years ago #

    Have you defined a twentyten_setup() function in your child theme's functions.php?

    * To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's
     * functions.php file.

    If you don't, Twenty Ten's version of it will be run and it calls add_editor_style().

Topic Closed

This topic has been closed to new replies.

About this Topic