WordPress.org

Ready to get started?Download WordPress

Forums

Not Able to Load CSS File Into Admin Panel (3 posts)

  1. chaseman
    Member
    Posted 3 years ago #

    I've created my own admin panel for the theme I'm developing, now I want to style it up but I'm not able to load the CSS file into the admin panel. I've done it the same way how the Codex showcases it.

    This is the code in functions.php

    function chase_admin_panel_init () {
    wp_register_style ('admin_panel_css', TEMPLATEPATH . '/admin_panel_css.css');
    }
    
    add_action ('admin_init', 'chase_admin_panel_init');
    
    function chase_admin_panel_style () {
    wp_enqueue_style ('admin_panel_css');
    }
    chase_admin_panel_style ();
    require_once (TEMPLATEPATH . '/blurb_panel.php');

    I register the CSS file (the path is correct I've already checked it), then I do the add_action, and then I create the function for enqueue_style, and THEN I call the function right BEFORE blurb_panel.php which contains the admin panel.

    Though, when I look in the admin panel, no changes take affect at all.

    Any ideas what I'm doing wrong?

  2. chaseman
    Member
    Posted 3 years ago #

    This does NOT work either:

    function chase_admin_panel_stylesheet () {
    wp_register_style ('admin_panel_css', TEMPLATEPATH . '/admin_panel_css.css');
    wp_enqueue_style ('admin_panel_css');
    }
    
    add_action ('admin_print_styles', 'chase_admin_panel_stylesheet');
    
    require_once (TEMPLATEPATH . '/blurb_panel.php');
  3. chaseman
    Member
    Posted 3 years ago #

    Ok I have to correct myself, the path was NOT correct, I was using a path which is meant for local files only and not for a web friendly path, this one will work:

    function chase_admin_panel_stylesheet () {
    wp_enqueue_style ('admin_panel_css', get_stylesheet_directory_uri() . '/admin_panel_css.css');
    }

    SOLVED!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.