It seems like you’re using dependencies the opposite way of how they should be used.
In the WordPress Codex, they try to explain how it’s supposed to be used.
$deps (array) (optional)
Array of handles of any stylesheets that this
stylesheet depends on. Dependent stylesheets will be loaded before
this stylesheet.
Since your style2.css
is used to make changes to style.css
, it means style2.css
is dependent on style.css
.
This is what your code should look like:
function wpb_adding_styles() {
wp_enqueue_style('main-css', get_template_directory_uri() . '/style.css', array(), '1.0', 'all');
wp_enqueue_style('style2', get_template_directory_uri() . '/style2.css', array('main-css'), '1.0', 'all');
}
Hope this helps!
Related Posts:
- How to load scripts/styles specific for a page
- Child Theme Not Overriding Parent Theme
- I can’t add CSS with functions.php
- Advanced method to control cache of enqueued style/script
- CSS style and app.js not loading
- Display random categories on the front page (Finding and Editing Theme Functions)
- Why I can’t add a CSS style in this WordPress theme?
- TinyMCE custom stylesheets for different post types
- Dequeue Scripts and Style for Mobile not working?
- Enqueue styles after a plugin
- How to add background image control to page admin controls?
- Dequeue a style file which is making website load slow!
- Register and enqueue style.css custom theme
- Enqueue Style Only On Certain Pages Not Working
- Why does the ‘wp_nav_menu’ function work only until a menu is created?
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- Child Theme files – what is needed?
- Theme Loading Into Dashboard
- Font Awesome 5 Free – far working but fas is not? [closed]
- enqueue styles for only mobile wp
- different style sheet for just one page template
- Not all CSS elements transferring via parent to child?
- Split Media Queries in different files!
- get_template_directory adding FTP root folders in urls
- Having issue with WordPress wp_enqueue_style
- theme style is applied on the dhasboard rather than the website
- How to insert class in each list of categories?
- Parent theme styles overriding child theme CSS [closed]
- Theme JS is available but theme CSS isn’t
- Proper Way to Load stylesheet on Condition
- Getting the teaser text without overriding global variables
- Default Nav Highlight
- why can’t i add front.css to my frontpage.php
- get_template_directory_uri() links to child theme not parent
- “options.php” not found
- Page Template Won’t Load Correct CSS File
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- Can’t change theme name
- Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?
- How to reference different css (bootstrap) stylesheets for the header and body of a page?
- Test CDN link from function.php or wp_enqueue_script/style?
- Stylesheet does not load despite functions.php
- Setting Up Child Theme To Take Priority
- How do I dequeue a Stylesheet, stored in an ‘Assets’ folder?
- Child Theme not loading multiple stylesheets
- Random text changing to weird icons in both admin & front end
- Should I use `get_stylesheet_uri()` or `get_template_directory_uri()` when calling my CSS Stylesheet?
- Add custom css to theme
- Why don’t ‘wp_nav_menu’ CSS classes work until a menu is created?
- How to get postId from the argument $block when register_block_type()?
- wp_head not injecting css
- How to use webpack in WordPress theme? I want some scripts to load in the footer, some in the header and some with script parameters
- How to add CSS class to custom logo?
- How to add custom css file in theme?
- How important is it to enqueue a theme’s stylesheet?
- remove_action on after_setup_theme not working from child theme
- Issues with title-tag and document_title_parts
- Is there any global functions.php file which works for any theme?
- Do I actually need to link my theme’s style.css in the theme files
- Using classes instead of global functions in functions.php
- Enqueue a stylesheet for login page and make it appear in head element
- Child theme – Overriding ‘require_once’ in functions.php
- CSS classes for theme
- Is it ok to use a function to output the text domain name in a wordpress theme
- Are the WordPress Core CSS styles really all nessesary?
- How to get woocommerce inventory status [closed]
- functions.php inject inline css
- Issue with get_theme_mod returning a blank value instead of the saved value
- TinyMCE custom styles remove class when switching styles
- How to make a theme with more than one CSS file?
- Editing the custom background CSS
- How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?
- How do I create a new WP admin color scheme?
- Logout/login redirect CSS issue
- Hourly Routine Not Firing ( wp_schedule_event() )
- What can I hook into after_setup_theme?
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- How to get the registered sidebar’s name by its id?
- Add attribute to link tag that’s generated through wp_register_style?
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- Organize functions.php
- How to add the main style.css to my index.php?
- How to override functions.php in child theme?
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- which is the function that removes accented vowels?
- Overriding core functions in child theme
- One button to change all settings in theme customizer?
- is_front_page not working in functions.php
- Adding inline styles from a widget
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- Change parent theme file function in child themes functions.php
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- Theme Demo in live Site
- Removing the default sidebar from admin panel
- Remove “says” from comments
- Add inline css to theme
- Is there an error in get_the_tag_list()?
- Customising widget titles/headings in WP 5.8
- How to add CSS style sheet dynamically in wordpress