I would like to get html class names same way get_body_class() works but on the admin side. I would like to change body class names of TinyMCEs iFrame element to allow specified editor-styles.css styles work only when editing page with .page and .home classes.


body.page.home table td:nth-child(2) {

This is not working:

add_filter('tiny_mce_before_init', function($init_array) {

    //var_dump(get_option( 'page_on_front'));
    if (is_front_page()) {
        $init_array['body_class'][] = 'home';
    if (is_page()) {
        $init_array['body_class'][] = 'page';
    if (isset($init_array['body_class']) && is_array($init_array['body_class'])) {
        $init_array['body_class'] = implode(' ', $init_array['body_class']);

In other words:

How to specify custom editor-styles for TinyMCE for just one exact page (in my case it is home page).

1 Answer 1


If I understand you correctly, you want a custom editor style when editing the homepage? You can check if you're currently editing the homepage by comparing the post ID to the ID in the page_on_front option, like this:

function homepage_editor_styles() {
    global $post_ID, $post_type;

    if ( empty ( $post_ID ) || 'page' !== $post_type )
    if ( $post_ID === (int) get_option( 'page_on_front' ) ) {
        add_editor_style( 'css/editor-style-homepage.css' );
add_action('admin_head', 'homepage_editor_styles');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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