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 add CSS class to custom logo?
- How to get woocommerce inventory status [closed]
- How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?
- What can I hook into after_setup_theme?
- Organize functions.php
- How to add the main style.css to my index.php?
- How to override functions.php in child theme?
- One button to change all settings in theme customizer?
- Adding inline styles from a widget
- Removing the default sidebar from admin panel
- I created a child theme and it doesn’t work for some of the css files
- Enqueued Stylesheets Effecting Admin Styles
- How to override enqueued styles using a child theme
- Changing itemprop from logo to image on custom logo?
- Where is definied the theme location for the main menu in a WordPress template?
- How to call custom function from functions.php in site-wide template files?
- How to enable template page only for a post id page
- WordPress Menuing Question :focus
- Is there an alternative to get_template_directory_uri()?
- create filter in functions.php
- Remove stylesheets from Campaign Monitor plugin
- How remove render blocking css from wordpress when you build a theme?
- Redirect to another page using contact form 7? [closed]
- Plugin and themes are adding the same stylesheets
- get_pages() Returns Only One Item
- Theming Using Bootstrap Glyphicons and WordPress Dashicons
- How to pass variables from one function to another or combine functions
- LESS not working in WordPress [closed]
- How to override this theme function in child theme
- How to use the _S framework
- What function actually renders the wp_admin_bar ? How can I call it?
- Load CSS before Theme CSS
- Can’t load assets
- How to add styles in existing function?
- How to generate a rtl.css file for themes?
- How to retrieve image IDs from shortcode content?
- I need to ‘wp_dequeue_script’ and ‘styles’ and ADD a bunch of other css and js
- Correct way of Enqueue self hosted fonts in sass project
- Class::$template_dir_path=get_template_directory();
- Language switcher for subdomains
- How to add next height number in Order Attributes inside the Add new page. [duplicate]
- Functions.php in child theme that loads CSS file breaks website
- Print all inline styles to head
- How does child theme functions.php work with parent theme functions.php? Is it like CSS? [duplicate]
- adding navigation to genesis themes
- WordPress is adding pagination for all pages not only for blog page, How to remove pagination for all pages except blog/posts page?
- My website is generating weired url parameters of paginated pages
- how to display custom taxonomies in front page