Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress How to Build a WordPress Plugin Building a WordPress Plugin Settings Page Adding CSS to WordPress Plugin Settings Pages

Jennifer Crawshaw
Jennifer Crawshaw
17,878 Points

CSS styling not showing up on Plugin Settings Page

I followed the instructions exactly to enqueue the stylesheet for the Plugin settings page, however, it is not applying the styles, so it must not be linking up properly. Can anyone help troubleshoot? My php code for the main plugin:

/*
 *  Plugin Name: Official Treehouse Badges Plugin
 *  Plugin URI: http://wptreehouse.com/wptreehouse-badges-plugin/
 *  Description: Provides both widgets and shortcode to help you display your Treehouse profile badges on your website
 *  Version: 1.0
 *  Author URI: Zac Gordon
 *  Author URI: http://wp.zacgordon.com
 *  License: GPL2
 *
*/

/*
 *  Assign Global Variables
*/
$plugin_url = WP_PLUGIN_URL . '/wptreehouse-badges';


/*
 *  Add a link to our plugin in the admin menu
 * Under 'Settings > Treehouse Badges'
*/

function wptreehouse_badges_menu() {

  /*
   *  Use the add_options_page function
   *  add_options_page( $page_title, $menu_title, $capability, $menu-slug, $function )
   *
  */

  add_options_page(
      'Official Treehouse Badges Plugin',
      'Treehouse Badges',
      'manage_options',
      'wptreehouse-badges',
      'wptreehouse_badges_options_page'
    );

}
add_action( 'admin_menu', 'wptreehouse_badges_menu' );


function wptreehouse_badges_options_page() {

  if( !current_user_can( 'manage_options' ) ) {

    wp_die( 'You do not have permission to access this page.' );

  }

  global $plugin_url;

  require( 'inc/options-page-wrapper.php' );

}

function wptreehouse_badges_styles() {

  wp_enqueue_style( 'wptreehouse_badges_styles', plugins_url( 'wptreehouse-badges/wptreehouse-badges.css' ) );

}
add_action( 'admin_head', 'wptreehouse_badges_styles' );



?>```