WordPress.org

Ready to get started?Download WordPress

Forums

targeting a specific admin page in editor-style.css (3 posts)

  1. cruxwireweb
    Member
    Posted 1 year ago #

    I have a client whose website has a dark background, on which he sometimes uses white text. He's not very tech-savvy, and although I've told him he does not need to change the text to white in the back end, he does so anyway, and thus it's white text on a white background. So, via editor-style.css, I'm changing the editing area background to a dark color so he can see his text.

    The hitch is that there is an announcement area on the home page that has a white background. This area is set up as a page named "Announcements" in the back end. Since he uses dark text in this area, it can't have a dark background in the editing area.

    So, what I need to do is target a background style to the editing area of this page only.

    In the front end, I'd target specific pages by using the body class for the page, but I don't see unique body classes for the back end pages.

    I wasn't sure if is_page works on the back end, so I tried this in functions.php without success:

    function custom_admin_styles() {
        if (is_page(112) && is_admin() ){
    		echo '<style type="text/css">.mceIframeContainer { background:gray; }</style>';
    	}
    }
    add_action('admin_head', 'custom_admin_styles');

    (Gray was just for testing, it'll be white once I figure it out.)

    Can anyone help me figure out how to do these, either via editor-style.css or a function? (Or any way that works?)

    Thanks,
    Kim

  2. cruxwireweb
    Member
    Posted 1 year ago #

    Also - this is a custom theme based on Twenty Ten.

  3. michael@darkemediagroup.com
    Member
    Posted 1 year ago #

    Hey, sorry its been so long but I just noticed your post.

    I tried this code and it worked

    function custom_admin_styles() {
        if ($_GET['post'] == 112 && is_admin() ){
    		echo '<style type="text/css">.mceIframeContainer { background:gray; }</style>';
    	}
    }
    add_action('admin_head', 'custom_admin_styles');

    This assumes you are editing a specific page. I think I understood that's what you were looking for. Now, the editor for page 112 will have a grey background. The others will be normal.

    Hope this helps

Topic Closed

This topic has been closed to new replies.

About this Topic