/**
* Enqueue stylesheet before others
*/
class EnqueueStylesheetEarly {
function __construct() {
add_action( 'wp_enqueue_scripts', [ $this, 'load_before_other_stylesheets' ], 5 );
}
/**
* Register and enqueue stylesheet
*/
function load_before_other_stylesheets() {
wp_register_style(
'bootstrap-css',
plugin_dir_url( __FILE__ ) . 'bootstrap.min.css',
[],
'3.3.7'
);
wp_enqueue_style( 'bootstrap-css' );
}
}
Then you can load this with your other frontend classes in your ‘plugin.php’ Like so…
if ( ! is_admin() ) {
require 'class-enqueue-stylesheet-early.php';
}
At a 5 priority, this should solve your problem. The only thing that usually loads before this is WordPress SEO JSON-LD scripts and meta.
Related Posts:
- Should I use RIPS tool to test my themes and plugins?
- Workflow and best practice for documentation [closed]
- How to get current post user id
- Redirect to another page using contact form 7? [closed]
- How do I combine a theme with a plugin
- How to write “alt” tag in image for wordpress code?
- Don’t load the theme for a page FROM a plugin EDITED
- Extending a theme: build new features as plugin or core modules?
- How do you create a re-useable HTML fragment in wordpress
- How to override any plugin file in the child theme
- when i activate my WordPress plugin cannot see customizer options or preview
- Why the output of an image gallery plugin is not displayed into a page of my custom theme?
- Breadcrumb is not generating the correct post page url
- Site is setup statically – how to make it content managable?
- How to escape html code?
- How to make content as required in custom post type?
- What is the correct way for a theme to support plugin UIs?
- How to call “page specific menu items” in template [closed]
- Update Multiple Post Meta for the Same Post In One call?
- Function to activate WordPress theme inside a plugin
- How do I make my wordpress page more friendly for mobile viewers?
- How to load a new template page according to a particular URL?
- Check javascript file Proper way in functions.php
- Make the css of the widget overwrite theme css
- How to Build a Movie Library in WordPress 3.x
- How do I register a stylesheet inside a WordPress widget?
- Display future posts?
- Override the core function locate_template
- Having separate plugins and themes folder for multi-site setup
- How can I get full attachment url from wp_get_attachment_metadata?
- unzip a folder on specific location and delete the zip file
- gallery option is not available in media upload box in costum theme option page
- Why are some of my thumbnails not being generated?
- Why is the Settings API is not saving my array of options
- ‘Customize’ button in admin bar for CSS
- WooCommerce get_price returning wrong price when used via ajax
- Open Post Thumbnail in New Child Theme File in WordPress
- How to use get_theme_mod in gutenberg editor wordpress?
- Reusable functions and tools (Framework)
- plugin style conflicts, how to override? [closed]
- Globally register styles but enqueue them selectively
- Classified ad website : which solutions to use? [closed]
- What are the specifics of WordPress development I need to know? [closed]
- How to create a code editor for my plugin .?
- Finding the URL to be used to check if plugin is installed with a theme
- wp_footer hook only working on homepage not in other pages
- Adding CSS to custom post type admin page causes error
- how to force tag page layout to use same as search layout?
- Great blogs site resources/tutorial for WordPress Developers? [closed]
- Create custom pages with a plugin
- Use different single.php file based on condition
- Making that Admin Bar transparent or a blue color
- Release the plugin in the WordPress repository where redux is used
- Images under 1MB are not being compressed
- Override/ignore CSS from active theme as not to interfere with my custom CSS
- How to use the CSS of the WordPress core in the development of my administration page?
- How can I use my custom wordpress theme on two websites? [closed]
- why need theme,if page builder is there in wordpress [closed]
- WordPress API functions not working at AJAX functions.php call
- What’s the right way to implement functions in footer.php
- Custom CSS not being added by plugin
- How to check homepage contain blog post?
- how to design change in woocommerce cart page and all other page also by theme? [closed]
- The Events Calendar Plugin – List View Background Colour Issue [closed]
- WordPress plugin with its own “site”/theme
- Identify current wordpress theme
- Removing the custom_image_header from wp_head
- Themes conflicts and overrides my WordPress Support widget Plugin styles
- Seperate plugin and theme files
- Xamp installed local wordpress not allowing to publish or install plugin
- Two plugins using the same CSS id
- Elementor Sidebar not loading when PRO elements plugin is active
- Widgets are not displaying in the admin panel
- submit two file input fields in the same form
- Content-Security-Policy implementation with WordPress W3Total Cache plugin installed
- woocommerce: Customize email with item total count
- Child theme modifications not showing up
- how to change a static testimonials into dynamic
- Rename a folder via HTML POST request
- How can I see $post object in frontend from functions.php?
- Link custom post type to page
- Showing different js file for different theme in wordpress customizer api
- WordPress panel is not loading after plugin activated with error: HTTP ERROR 500
- When the user entered an unauthorized url redirect to login page
- Help Code Review – I need to write on .htaccess file from theme’s function.php
- Where do the section input fields values are stored in database
- Get plugin to background of page
- Speed issues because of CSS & JavaScript
- How to show post attachment image
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- What is the Object for WP_Error Class?
- Active Plugins for current blog in WP Multisite Network? [duplicate]
- Disqus plugin outputs script as literal text
- How to get current template file used by WordPress?
- How to generate a responsive output from plugin?
- How to work email subscribe in WordPress?
- How to create post comparison in wordpress
- Editing a theme
- how to make wordpress remember my choice
- Meta box not displaying on the plugin page