Get URL of a Plugin File
If you want to get the URL of a plugin file (e.g. a CSS file), use the snippet below:
plugins_url( 'css/style.css', __FILE__ );
To include the CSS file, add this:
add_action( 'wp_enqueue_scripts', 'wpkb_add_custom_stylesheet' );
function wpkb_add_custom_stylesheet() {
wp_enqueue_style( 'my-stylesheet', plugins_url( 'css/style.css', __FILE__ ), array() );
}
Related Posts
- Tutorial: Ubuntu 18.04 LAMP Setup for WordPress
- Use Google Fonts Locally With GeneratePress
- Fix "Failed to get metadata: Local: Broker transport failure" When Updating Sentry
- Debug Pending WordPress Updates
- Add Custom CSS Styles to WordPress Visual Editor
- Avoid WPForms Spam by Implementing a Custom Honeypot
- Add self hosted Google Fonts to your Laravel App