Title: Replace a stylesheet via function.php in child theme
Last modified: August 20, 2016

---

# Replace a stylesheet via function.php in child theme

 *  Resolved [dreamingof8a](https://wordpress.org/support/users/dreamingof8a/)
 * (@dreamingof8a)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/replace-a-stylesheet-via-functionphp-in-child-theme/)
 * Hi fellow coders,
 * In the parent theme, a stylesheet is loaded in function.php via
    `wp_enqueue_style('
   layout', 'stylesheets/layout.css' );`
 * I would like to replace this file with my own layout.css in child theme folder(
   I already tried simply adding the relevant styles to my child’s style.css but
   this didn’t do anything).
 * My approach is:
 *     ```
       function child_enqueue_style() {
            wp_dequeue_style( 'layout' );
            wp_enqueue_style( 'layout_child', 'stylesheets/layout.css' );
       }
       add_action( 'init', 'child_enqueue_style', 11 );
       ```
   
 * Note that the second layout.css is the one in a sub directory of my child theme.
 * However it is still only loading the original layout.css.
 * Any idea what to do?
    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/replace-a-stylesheet-via-functionphp-in-child-theme/#post-2931959)
 * Never tried it but you will have to dequeue after the parent stylesheet has been
   enqueued, not before. It looks like you are dequeueing before the parent stylesheet
   is enqueued, which as you noted does nothing.
 * Is the parent stylesheet loaded on a hook, like you are doing, or is the function
   raw in functions.php? If it is on a hook, try hooking to the same hook, and mess
   with the ‘priority’ value if you have to. If it isn’t on a hook you will have
   to find a hook that will work, maybe [`after_setup_theme`](http://codex.wordpress.org/Plugin_API/Action_Reference/after_setup_theme)
 *  Thread Starter [dreamingof8a](https://wordpress.org/support/users/dreamingof8a/)
 * (@dreamingof8a)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/replace-a-stylesheet-via-functionphp-in-child-theme/#post-2931966)
 * The original enque is inside a function, which is then call via
    `add_action('
   wp_enqueue_scripts', 'function')`.
 * I tried your suggestion using àfter_setup_theme` but no luck.
 * Do you know of any list where I can see the order of all actions? Can’t seem 
   to find it in the codex …
 *  Thread Starter [dreamingof8a](https://wordpress.org/support/users/dreamingof8a/)
 * (@dreamingof8a)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/replace-a-stylesheet-via-functionphp-in-child-theme/#post-2931969)
 * Okay I guess it was easy in the end – just used the same hook `wp_enqueue_scripts`–
   that seems to do it. Thanks for pointing me in the right direction!
 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/replace-a-stylesheet-via-functionphp-in-child-theme/#post-2931970)
 * > The original enque is inside a function…
 * But is that function loaded on a hook? That is the important part.
 * I used to know of a list of hooks in order but I haven’t been able to find it
   in quite awhile. Yes, it would be a very nice thing to have. There is a plugin
   called [WordPress Hook Sniffer](http://wordpress.org/extend/plugins/wordpress-hook-sniffer/).

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Replace a stylesheet via function.php in child theme’ is closed to new
replies.

## Tags

 * [child](https://wordpress.org/support/topic-tag/child/)
 * [dequeue](https://wordpress.org/support/topic-tag/dequeue/)
 * [Stylesheet](https://wordpress.org/support/topic-tag/stylesheet/)

 * 4 replies
 * 2 participants
 * Last reply from: [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/replace-a-stylesheet-via-functionphp-in-child-theme/#post-2931970)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
