• Custom css works when in, Customizer/Additional CSS; but once i delete from here and save to style.css in child theme, the customization disappears. Meaning not pulling the css from the file!

    1) The most recommend way in general, and also most secure, to avoid loosing customization on upgrade, is to have the custom css in style.css in the child theme, right?

    I don’t know much about php yet although i followed the child theme codex:
    https://codex.www.ads-software.com/Child_Themes

    Here’s my functions.php code in case you can help.

    <?php 
    function my_theme_enqueue_styles() {
    	
    	$parent_style = 'onetone-style'; // This is 'Onetone-style' for the Onetone_Child theme.
    	
    	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 ),
    		wp_get_theme()->get('Version')
    	);
    
    }	
    
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    
    ?>
    
    
Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator t-p

    (@t-p)

    1) The most recommend way in general, and also most secure, to avoid loosing customization on upgrade, is to have the custom css in style.css in the child theme, right?

    A custom CSS editor (usually titled Additional CSS) is included in the Customizer as of WordPress 4.7 specifically for this purpose.

    As an alternative, especially if you intend to modify more than just CSS, create a child theme.

    Thread Starter johnatanasoff

    (@johnatanasoff)

    @t-p

    I already a have a child theme!
    But the website is not being affected by the css code in style.css
    This is the problem i described!

    – Have you got any idea why?

    – Also from what i remember reading; having the css in Customizer/Additional CSS is not the best way as you can loose it upon upgrading. I am right?

    Moderator t-p

    (@t-p)

    Custom css works when in, Customizer/Additional CSS;

    If all you are doing is changing CSS, then just stick to Additional CSS included in the Customizer. Also, as you said css works when in, Customizer/Additional CSS!!!!!

    Thread Starter johnatanasoff

    (@johnatanasoff)

    @t-p

    Is it wipe out safe? When doing a theme upgrade?

    Still style.css is supposed to work, so i will try find how? ??

    Is it wipe out safe? When doing a theme upgrade?

    Yes, any CSS code that you add to the Additional CSS function of WordPress will not be lost when you upgrade a theme. If you are only adding a few lines of css, this is definitely the way to go.

    Thread Starter johnatanasoff

    (@johnatanasoff)

    @kjodle

    Good to know ?? Thanks!

    Though i am looking to do more customization in this specific theme; and through the customizer isn’t the best way.
    Have you developed a child theme and added css to style.css successfully?

    Anything i should have in mind?

    Have you developed a child theme and added css to style.css successfully?

    Yes. There are plugins that will create child themes for you.

    I created my own theme for my websites. You can see the original theme on Github:

    https://github.com/kjodle/Atticus-Finch

    and you can see the child theme I created for it as well:

    https://github.com/kjodle/atticus-finch-child

    That should serve as a model for your own child theme. If you get stuck, don’t hesitate to ask!

    Thread Starter johnatanasoff

    (@johnatanasoff)

    @kjodle Thanks a lot!

    I’l have a look at your themes ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Child theme css. Recommendation and problem.’ is closed to new replies.