Skip Navigation

[Closed] get child theme css to override parent (toolset starter)

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 11 replies, has 3 voices.

Last updated by Waqas 5 years, 10 months ago.

Assigned support staff: Waqas.

Author
Posts
#325310

I am trying to: get child theme css to override parent theme

I visited this URL: hidden link

I expected to see: transparent background on nav menu

Instead, I got: blue background

I added this to child theme's functions.php:

add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array('parent-style')
);
}

#325505

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

You can directly import your parent-theme style.css by @import url('../parent-theme-name/style.css'); in your child-theme style.css and below it write your own css code or override the parent-theme css code.

In this case, you only enqueue your child theme's CSS in child theme's functions.php file.

However, there's another solution, but more technical, please have a look at https://wordpress.org/support/topic/child-theme-stylecss-not-overriding-parent#post-1969406

Please let me know if I can help you with anything related.

#325617

I don't understand why this is so complicated. I've built many child themes, and I've never needed anything more than an @import statement in my child theme's style.css file. What makes the toolset-starter theme different? Bootstrap?

#325826

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I apologize for this complication and confusion. This has recently been reported by a few clients and I have just escalated the issue to the relevant Dev Team, for a suggestion. Since the guidelines provided at https://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme should be working generally, but looks like there's a reason for it.

I or anyone from the escalated team will keep you posted about the progress. Thank you for your patience and cooperation.

#325929

If you could provide blank child themes for your toolset-bootstrap and toolset-starter themes, with the necessary code already in functions.php to enqueue the css properly, that would be a big help. Or just provide the enqueueing code for those themes so that those of us who don't know much php can just copy and paste it into our child themes' functions.php.

I would love to get started using one of your themes and the layouts plugin, but I just don't have time to figure this out, so I'm going back to Woothemes Canvas for now.

#326094

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your suggestion, I have forwarded this to the Dev Team as well.

#326638

Hi,

I have similar problem.

style.css from child theme is override by parent theme.css (why?)

Please provide me clear information how to make it works.

This should just works without hacking code :/

#326647

Found solution here: https://toolset.com/forums/topic/child-theme-for-toolset-bootstrap/

But IHMO it is not good solution (good for the moment) - plugins should not change wordpress philosophy.

#329627

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I just heard back from the Dev Team and they have acknowledged the issue. But in fact, problem isn't happening only in the Toolset Starter theme but in any theme that enqueue styles in the functions.php. Exactly what Toolset Starter is doing, it's calling a few different css files in the functions.php.

Child themes just have priority over the main css file (styles.css). The WP calls child functions.php first, then parent functions.php. So you can't just dequeue the style in the child because it wasn't enqueue yet.

So, the only rules you can replace are the ones inside of the main styles.css file.

However, they are preparing a child theme, but don't have an ETA for now. Hopefully, this will be released soon and the said issue will be resolved.

Thank you for your understanding and cooperation.

#334442

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

We have released the Child Theme for Toolset Starter. It is available for download at https://toolset.com/account/downloads/#toolset-themes

Toolset Starter itself was also updated and it needs to be updated in order to make the Child theme work properly.

Documentation will be updated soon but I guess the new theme itself is rather self explanatory.

#334621

Thanks, but the download links on your themes page seem to be broken.

#334984

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Please try again, I have just verified and it seems to work correctly. Remember to login to your wp-types.com account first.

The topic ‘[Closed] get child theme css to override parent (toolset starter)’ is closed to new replies.