• Resolved DivTag

    (@divtag)


    Hi,

    I have had a browse and cannot seem to find out how to do this, unless I am just missing something obvious.

    I am trying to attach some CSS within <style> tags as it will be containing php, like you would put in the header.php file on a normal page, however this does not get included on the admin pages.

    Whats the easiest way to do this?

    Cheers

    Chris

Viewing 7 replies - 1 through 7 (of 7 total)
  • add_action( 'admin_head', 'admin_css' );

    function admin_css()
    {
    echo '<link rel="stylesheet" type="text/css" href="LINK TO YOUR STYLESHEET">';
    }
    Thread Starter DivTag

    (@divtag)

    Hi Nate,

    Thanks for your reply, but I dont want to enqueue an actual style sheet, as I cannot use php in a .css file, I want to add CSS between style tags in the head, eg..

    <style>
    .background_<?php echo $background ?> {
    border:2px solid blue;
    }
    </style>

    Any ideas?

    Cheers

    Chris

    You can just “echo” this instead of Nate’s ‘link’ code, right?

    <style>
    .background_<?php echo $background ?> {
    border:2px solid blue;
    }
    </style>
    add_action( 'admin_head', 'admin_css' );
    
    function admin_css(){ ?>
         <style>
         .background_<?php echo $background ?> {
              border:2px solid blue;
         }
         </style>
    <?php
    }

    or that ??

    Thread Starter DivTag

    (@divtag)

    Fantstic!

    Thanks Voodoo!

    For sure!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to add css to head of admin page’ is closed to new replies.