TransWikia.com

In editor-style.css how can I change background color of title field?

WordPress Development Asked on January 10, 2021

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;
} 

One Answer

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;
}

Answered by Dave Romsey on January 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP