he css code added to style css does not work
-
Hello, when I add my own customization code to a css style in a child theme, this style does not work.
The changes I make don’t work. If I add such a code in the Kadence settings, an additional code, they work correctly. However, I wanted to add these codes to the css style and not in the kadence settings.
Why is it that the css code works only in the additional style settings in customize Kadence – but it doesn’t work when added to style.css in a Kadence child theme?
-
Hello @danishsard,
Here is a page about child themes provided by Kadence: https://www.kadencewp.com/help-center/docs/kadence-theme/what-is-a-child-theme-should-i-install-one-if-so-how/. Can you let us know if the instructions about loading the child theme style.css file helps? It reads:
Load child theme style.css file.
If you want to have the child theme enqueue your child theme style.css file you can navigate to the functions.php file of the example child theme, at the top you will see:
/** * Enqueue child styles. */ function child_enqueue_styles() { wp_enqueue_style( 'child-theme', get_stylesheet_directory_uri() . '/style.css', array(), 100 ); } // add_action( 'wp_enqueue_scripts', 'child_enqueue_styles' ); // Remove the // from the beginning of this line if you want the child theme style.css file to load on the front end of your site.
Remove the // before the add_action and your child theme style.css will be enqueued.
When I delete this line of code I get this error at the top of the page.
The website works but there is a stenl message at the top of the error./** * Enqueue child styles. */ function child_enqueue_styles() { wp_enqueue_style( ‘child-theme’, get_stylesheet_directory_uri() . ‘/style.css’, array(), 100 );
If I add the code you provided, I get the following error message:
/** * Enqueue child styles. */ function child_enqueue_styles() { wp_enqueue_style( ‘child-theme’, get_stylesheet_directory_uri() . ‘/style.css’, array(), 100 ); } // add_action( ‘wp_enqueue_scripts’, ‘child_enqueue_styles’ ); // Remove the // from the beginning of this line if you want the child theme style.css file to load on the front end of your site.
My code in functions works well in the child theme – unfortunately, what is in the css does not work – as if it were not there.
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}- This reply was modified 10 months, 1 week ago by Danishsard.
Hello @danishsard,
Did you remove the line of code or only remove the “//” at the start of the code. The line should simply read:
add_action( 'wp_enqueue_scripts', 'child_enqueue_styles' );
<font _mstmutation=”1″></font>Yes, and then there is this error
/** * Enqueue child styles. */ function child_enqueue_styles() { wp_enqueue_style( 'child-theme', get_stylesheet_directory_uri() . '/style.css', array(), 100 ); } add_action( 'wp_enqueue_scripts', 'child_enqueue_styles' );
Can anyone help, where are the CSS codings from Kadence? There are no codes in style.css, and the custom styles added there do not work.
When adding the above code, the website has an error visible under the menu bar.
Hello @danishsard,
You mentioned there is an error. Can you explain the error in more detail? What is the error and what happens when the error is triggered? Do you have screenshots of the error or provide the error text?
<font _mstmutation=”1″></font>
I have already provided the error message above. How do I follow the blanket you gave me?
We also ask where the Kadence styles are – because there is nothing in style.css anymore – and they used to be.
Hello @danishsard,
I’m not sure what you mean when you say the error is:
<font _mstmutation=”1″></font>
/** * Enqueue child styles. */ function child_enqueue_styles() { wp_enqueue_style( 'child-theme', get_stylesheet_directory_uri() . '/style.css', array(), 100 ); } add_action( 'wp_enqueue_scripts', 'child_enqueue_styles' );
That is the code I’ve seen provided in this thread. Neither of them are errors. What do you mean you get an error? Does your page crash? Do you have an error in your error logs? Is there some sort of red text that appears in the editor?
When you make a child theme, you have a new directory with new functions.php and style.css files. The Kadence theme styles remain in the Kadence directory. Your new style.css file can be enqueued as well with the wp_enqueue_scripts action. However, you’re saying you get an error, but I don’t understand your error. That is why I ask for the error text or a screenshot of the error. None of the text in this thread has been from an error.
When I add the code you provided – without or with deletion //, the error on the page looks like this:
Even when I add everything and it pulls the CSS styles from the kid theme. These are just some, not all.
HR – the line is from the css globe – downloaded, not the child, the child contains comment keys, for example, and their borders. But HR styling – not at all.
This is so crazy.
However, adding these codes to customize the theme always works – but not from the child theme, even if I call it with the code you provided.
This is when some stylings work and others do not – some are taken from the child – and others from the global one.
But never parent all come from child – that’s crazy.
I add
.comment-body {
border-bottom: 2px dashed #000000;}Either in customize theme or in css – and it still takes a different look from global css this:
.comment-body {
position:relative;
border-bottom: 1px solid var(–global-gray-500);
margin-bottom: 3em;
}You have messed something up in the operation of this template and everything is starting to work strangely and inconsistently.
Even though there is child-style CSS code, I have to add the !important rule – otherwise the globas.css rule of the template is displayed in some elements. Not all of them, but in many of them.
- This reply was modified 10 months ago by Danishsard.
- This reply was modified 10 months ago by Danishsard.
- This reply was modified 10 months ago by Danishsard.
- This reply was modified 10 months ago by Danishsard.
- This reply was modified 10 months ago by Danishsard.
Hello,
Did you add the code to the functions.php file in the child theme? Can you provide the child theme? If not, can you list the directory structure in your child theme and the code in the functions.php file?
Does the “error” appear on every page on the site? It looks like the code is added as text instead of as code.
Hello, I managed to solve the error.
However, the parent CSS file of the child theme still does not work over some of the styles from the global CSS of the parent theme.
I still need to set IMPORTANT for the child theme with this code to work. Because half of the things are taken from the parent anyway, and some from the child – it is not known why this happens.
The structure of a child theme is simply the child directory – and the style.css and funcjtions.php files in it.
- This reply was modified 10 months ago by Danishsard.
Hi there!
Please note that we can assist you with code customizations but the implementation should be mainly done by you.
To better have an idea of your setup and the issue with styles, could you give us a website URL to check the styles? Also, what is the full code you have in your child theme’s functions.php file?
On the other hand, I believe the issue here is that your child theme styles are applied first on the page than the parent theme styles. This is why the styles from the parent theme are the ones used by the elements.
You can try out some of the solutions from this post – https://blog.tawfiq.me/solved-css-styling-in-wordpress-child-themes-style-css-file-not-working/
Let us know how we can help you further with this.
Regards,
KarlaHi there,
This topic has been inactive for more than 2 months.
If you have further questions or need additional assistance, feel free to start a new topic or refer to our Kadence Theme documentation here: https://www.kadencewp.com/help-center/knowledge-base/kadence-theme/
Thank you for your understanding!
Kind Regards,
Michael Taro
- The topic ‘he css code added to style css does not work’ is closed to new replies.