1

When editing a page or post, I would like the title field to have a different background color from white. I have tried the following but it doesn't seem to work:

#titlediv #title {
    background-color: #ffffcc;
}

I know my editor-style.css is working, as I have changed the background color of the main content editor box with:

.mceContentBody.wp-editor {
    background-color: #ffffcc;
} 

1 Answer 1

1

Editor styles only apply to the TinyMCE content area. If you'd like to apply styles to other elements on the edit page, you'll need to enqueue a separate stylesheet.

For example, add this to the theme's functions.php:

function wpse250011_admin_styles( $hook ) {
    // Bail if we're not on the post.php admin page
    if ( 'post.php' !== $hook ) {
        return;
    }

    // Ensure we're looking at a post or page
    $post_type = get_post_type();
    if ( ! $post_type || ! in_array( $post_type, [ 'post', 'page' ] ) ) {
        return;
    }

    wp_enqueue_style( 'admin-edit-post-styles', get_template_directory_uri() . '/admin-edit-post.css' );
}
add_action( 'admin_enqueue_scripts', 'wpse250011_admin_styles' );

Add the styles for the admin components, such as the title field to a separate file: /your-theme/admin-edit-post.css

#titlediv #title {
     background-color: #ffffcc;
}

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.