Support » Fixing WordPress » How to use new add_editor_style() function

  • 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?

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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.

    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?

    Workaround specified doesn’t work around.

    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().

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to use new add_editor_style() function’ is closed to new replies.