I'm trying to add a stylesheet to the options page for my plugin - code looks like this:

add_action( 'admin_print_styles-rps-paypal', 'rps_paypal_add_css' );

function rps_paypal_add_css() {
wp_enqueue_style( 'rps_paypal', plugins_url( '/rps_paypal/css/rps-paypal.css' ) );

add_action( 'admin_menu', 'rps_myplugin_add_page' );

function rps_myplugin_add_page() {
    'My PayPal Plugin',
    'My PayPal Plugin',

Can't figure out why it's not showing up...

  • admin_print_styles should not be used to enqueue styles or scripts on the admin pages. Use admin_enqueue_scripts instead. – gurung Aug 25 '15 at 6:23

the call to add_options_page will return the string literal to use for your RSS, so it should look something like this:

$page = add_options_page( ... );
add_action( 'admin_print_styles-' . $page, 'rps_paypal_add_css' );

More info here: http://codex.wordpress.org/Function_Reference/wp_enqueue_style

  • You're welcome Richard. What Rast said below is true as well, you shouldn't hard-code your plugin name during the call to plugins_rss. – kovshenin Apr 29 '11 at 11:39

First I am not sure you get hook suffix right. It is return of add_options_page() function and from quick test should be something like admin_page_rps-paypal in your case. But really you should save that return in the variable and use that rather than hardcode it.

Second your plugins_url() usage is little off, your plugin's folder name is not guaranteed to be that. More robust to use it like:

plugins_url('/css/rps-paypal.css', __FILE__);
  • Hi Rarst, Thanks so much for this - this is my first attempt at writing a plugin so all advice is greatly appreciated! - R – Richard Sweeney Apr 29 '11 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.