0

I am writing a stylesheet that will help show the content in the TinyMCE editor look more like it would appear on the front end of the website using the add_editor_style function in the WordPress theme functions file. I may even end up adding a few style rules in the editor-style.css file just to be used on content.

So I am wondering if the styles added to the editor-style.css stylesheet are also loaded on the front of the website when the page gets rendered? I checked the WordPress documentation and I didn't see anything that specifically stated one way or the other.

add_editor_style( "editor-style.css" );

UPDATE

Here is the actual code from the themes functions file:

function custom_theme_features()  {
    add_editor_style( 'css/editor-style.css' );
}
add_action( 'after_setup_theme', 'custom_theme_features' );
1

Below is the full code to include the editor style in a common way.

<?php
function my_theme_add_editor_styles() {
add_editor_style( 'custom-editor-style.css' );
}
add_action( 'admin_init', 'my_theme_add_editor_styles' );
?>

When you are adding the custom editor style, you need to use admin_init hook which is triggered only when you are inside the admin panel. So the stylesheet will not load in the front end and is limited to admin dashboard.

| improve this answer | |
  • What if after_setup_theme is used in the add_action hook instead of admin_init? Will the editor styles be loaded on the front end then while still being loaded in the editor? I updated my question to show what I presently have in my theme. – Opaw Nako Apr 28 '15 at 19:12
  • 1
    I believe that styles added with add_editor_style do not appear in the front-end regardless of where they are loaded.That said, you should use the admin_init action hook since it will be more efficient and only run in the admin area =) – Ben Cole Apr 28 '15 at 23:23
  • I just checked the code using after_setup_theme, it doesn't load in front end either. So we can be assured add_editor_style doesn't append style to front end. – m4n0 Apr 29 '15 at 2:44
  • 1
    Thank you for following up. That is what I needed to know. – Opaw Nako Apr 29 '15 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.