• I’m following wordpress codex and trying to set up a child theme. I created functions.php and put the following code:

    <?php
    
    add_action( 'wp_enqueue_scripts', 'enqueue_child_theme_styles', PHP_INT_MAX);
    function enqueue_child_theme_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
        wp_enqueue_style( 'child-style', get_stylesheet_uri(), array('parent-style')  );
    }

    My child theme’s stylesheet has the following:

    /*
     Theme Name:   mythemename-child
     Template:     mythemename
    */
    
    /* =Theme customization starts here
    -------------------------------------------------------------- */

    I’m trying to overwrite some basic stuff like H1 and H2 font sizes but nothing I put into style.css seems to work. Do I need to edit something in the functions.php to include my actual theme name? I’m not a programmer and I can’t tell if I’m supposed to insert the actual name of my theme somewhere in the code where it says “enqueue_child_theme_styles”, etc.

    I literally copy and pasted the functions.php code from the wordpress codex site and didn’t change anything.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You don’t need to touch functions.php to have the styles.css file recognized when running a child theme. Just select the child them as the active them (after properly setting it up, of course), and you should be good to go.

    Thread Starter Ronnie55

    (@ronnie55)

    TY for the response, I appreciate it very much.

    So I have it set up. Both files are exactly as-is (shown above).

    I simply don’t understand where/how to paste code I want to overwrite.

    Here’s an example of some code I found on my paren’t themes stylesheet. I have no idea how to go about implementing changes. Nothing I seem to do actually makes a difference on one of my posts. I’ve tried changing h1 and h2 to size 8, nothing happens.

    h1{ font-size: 36px; }
    h2{ font-size: 28px; }
    h3{ font-size: 24px; }
    h4{ font-size: 22px; }
    h5{ font-size: 20px; }
    h6{ font-size: 18px; }

    I’m trying to reduce the H1 font size basically. Nothing I do works. I want to play around with it and try out 20, 25, etc. instead of 36

    Can you post a link to your site with the child theme active?

    Thread Starter Ronnie55

    (@ronnie55)

    The theme is Sympagrid

    (edited to remove URLs)

    What’s happening is that your child theme’s stylesheet is being loaded before your parent theme’s stylesheet, and because your parent theme’s stylesheet is loaded last, the browser uses the styles defined in that stylesheet instead of your child theme’s stylesheet.

    You might try using this code in your child theme’s functions.php, instead of the code you’re currently using:

    <?php
    
    add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
    function enqueue_parent_theme_style() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
    }

    As you are using a commercial theme, you should ask your theme’s vendor(s) if there are any special instructions for creating a child theme, as no one here has access to your theme.

    Thread Starter Ronnie55

    (@ronnie55)

    Okay thanks, I’ll try what you said, and then i’ll contact the theme developer.

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

The topic ‘Having trouble setting up child theme’ is closed to new replies.