• Skip to primary navigation
  • Skip to main content

RocketGeek

Home of WP-Members, The Original WordPress Membership Plugin

  • WordPress Plugins
    • WP-Members
      • FAQs
      • Quick Start
      • Documentation
      • Extensions
    • Advanced Options
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Download Protect
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Invite Codes
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • MailChimp Integration
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • PayPal Subscriptions
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Salesforce Web-to-Lead
    • Security
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Text Editor
      • Purchase the Plugin
      • Get the Pro Bundle
    • User List
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • User Tracking
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Memberships for WooCommerce
    • WordPass
  • Blog
    • Basics
    • Tips and Tricks
    • Filters
    • Actions
    • Code Snippets
    • Shortcodes
    • Design
    • Release Announcements
  • Store
    • Cart
    • Checkout
  • Contact
  • Log In
  • Show Search
Hide Search
Home » Tips and Tricks » Load a custom stylesheet with wp_enqueue_scripts

Load a custom stylesheet with wp_enqueue_scripts

Chad Butler · Mar 27, 2012 ·

This article is provided free. Find out how you can get full access to premium content, including how-to articles and support forums, as well as priority email support and member exclusive plugin extensions..

 

Setting up a custom stylesheet for the plugin gives your site a more polished and professional look as you can better integrate the look of the plugin’s forms to the look of your theme.

To get started, you can use any of the stylesheets included in the plugin as a framework, although this is optional. More importantly, you should save any customized stylesheet somewhere outside the plugin folder so it does not get overwritten when the plugin is upgraded.  This example assumes you’ve saved it in your theme folder.

WP-Members uses wp_enqueue_style to identify its stylesheet. This allows you to dequeue it so you can use your own stylesheet.

Disable the Default Styles

Once you have a custom stylesheet you will be working with, we will need to disable the default stylesheet. This is something you can do in your theme’s functions.php file. (Most themes have a functions.php file included. If your’s does not, simply create a file named functions.php, place your functions in it, and save it to your theme folder – it will load automatically.)

WP-Members registers its stylesheet with the handle ‘wp-members’. So first we will disable that from loading. This is done by adding the following to the functions.php file:

add_action( 'wp_enqueue_scripts', function() {
    wp_dequeue_style( 'wp-members' );
}, 15 );

This action will cause the existing styesheet to not load. Now we need to tell it to load our custom stylesheet.  Note the priority of 15.  We need to make sure this happens after the plugin enqueues the stylesheet (which happens at the default priority of 10).  If we try to dequeue it before, the plugin will be adding it after and it won’t be removed.  This is an example of where the action priority number is important to know and understand.

Load Custom Stylesheet

Now that the main WP-Members stylesheet is unloaded, we can load our custom stylesheet.

This example assumes your stylesheet is saved in your theme directory and is named “my-custom-stylesheet.css”.

Note the priority of 20.  We need this to come after we have removed (dequeued the original default stylesheet), which we did at priority 15 above.

add_action( 'wp_enqueue_scripts', function(){
    global $wpmem;
    $style_url = trailingslashit( get_template_directory_uri() ) . 'my-custom-stylesheet.css';
    wp_enqueue_style ( 'wp-members-custom-style', $style_url, false, $wpmem->version );
}, 20 );

Using these two actions you can unload the default stylesheet for the plugin and load your own custom styles. To use this to load your own custom stylesheet, change the path as indicated in the comments to the location of your stylesheet.

Tips and Tricks css, free, wp-functions, wp_deregister_style, wp_enqueue_scripts, wp_enqueue_style, wp_print_styles, wp_register_style

Ready to get started?

Join Today!

© 2025 · butlerblog.com · RocketGeek is built using WordPress, WP-Members, and the Genesis Framework

  • butlerblog.com
  • WP-Members Support Subscription
  • Terms of Service
  • Privacy Policy
  • Refund Policy