Child theme - enqueue

Hi guys,

I'm an idiot and can't figure this out for some reason (it's been a while working on child themes).

Here is the code to functions.php in our staging site child theme:

function my_theme_enqueue_styles() {
wp_register_style( 'parent_style', get_template_directory_uri() .'/style.css', array(), null, 'all' );
wp_register_style( 'parent_style_main', get_template_directory_uri() .'/css/main.css', array(), null, 'all' );
wp_enqueue_style( 'parent_style' );
wp_enqueue_style( 'parent_style_main');

add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );


We just can't get the headers, menus, etc. to style correctly even after we re-save all options, titles, headers, menus, etc.

Can you please help? We just need to create a child theme footer.php file (to troubleshoot google maps API).

Thanks so much,

  • Kasia Swiderska

    Hello Derek,

    What theme are you using? Sad fact is that there are some themes that will not work with child themes - and many themes have problem when it comes to options (options are working in parent theme - but not in child theme).

    However did you try using sample code from Codex - they are not recommending registering styles - enqueue is enough.

    kind regards,

  • Adam Czajczyk

    Hello Derek!

    Actually "The7" is very complex theme and like many of "ultimate purpose all-in-one highly customizable" themes it doesn't exactly follow all the WordPress standards.

    It's a premium theme to which I don't have access unfortunately but I'm telling this from my experience with sites of many other members of our community that are/were based on that theme and that I had a chance to work with.

    Dont' get me wrong please, I'm not saying that it's not the good theme - it's just that it's not so "standard" as it's claimed to be :slight_smile:

    Still though, the most basic example of enqueing styles that Kasia suggested theoretically should work with it. As it's not, I'd like to take a direct look at it but since I don't have an access to the theme I hope I could give it a try with your staging site.

    That said, if you are fine with letting me access your staging site so I could check it and hopefully find a solution please send in:

    Subject: "Attn: Adam Czajczyk"

    - Mark to my attention, the subject line should contain only: ATTN: Adam Czajczyk
    - Do not include anything else in the subject line, doing so may delay our response due to how email filtering works.
    - Link back to this thread
    - login URL and admin account login credentials (may be a temporary admin account) data
    - Include FTP log-in details (hostname, username & password)
    - Include hosting control panel access details (login address, username & password) - cPanel's usually the control panel used for this, but your provider may use something else; I may need this for accessing your site's database, preferably via phpMyAdmin
    - Include any relevant URLs for your site

    Please use our contact form here

    Select "I have a different question" from the drop-down list. 

    Best regards,

  • Adam Czajczyk

    Hello Derek!

    I received your e-mail and I think I made the child theme work for you. There were two issues that had to be addressed, one "general" and one specific to the The7 theme. See below :slight_smile:

    1. General style enqueueing

    The code that was in your child theme's functions.php file was fine except it only enqueued parent theme styles. Since all the CSS changes to the child theme should be made to the child-theme's style.css file it should as well be enqueued. I commented out your current code and used the generic one from WP Codex:

    function my_theme_enqueue_styles() {
        $parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen 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 ),
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );

    I then made sure that the styles are included as expected.

    2. The The7 theme issue

    I was a bit puzzled with this because I could see that the styles are included and the site seems to be working fine except the header and menus, just like you mentioned in your initial question.

    It turnes out that in case of The7 theme there's an additional step to be taken. When you activate the child-theme it reverts all the settings to default. The solution here is:

    - keep the parent theme active
    - go to "Theme Options -> Import/Export settings" page
    - copy entire "mambo-jumbo-code" from there :slight_smile:
    - enable child theme
    - got to "Theme Options -> Import/Export settings" page again
    - paste the copied code there and save settings
    - make sure that the page cache is cleared meanwhile.

    I already did that and it did the trick so currently the child theme is active and you should be able to proceed with further development. Just a side note: I would suggest keeping all the caches disabled during development for easier testing.

    Best regards,

  • Dimitris

    Hey there Derek,

    I trust you're doing good today and don't mind me jumping in here! :slight_smile:

    Could you please access your server through FTP, edit the wp-config.php file, find a line like
    define('WP_DEBUG', false);
    and replace it with the following (if the above line doesn’t exist, simply insert next snippet just above the /*That’s it! Stop editing… */ comment)

    // Enable WP_DEBUG mode
    define('WP_DEBUG', true);
    // Enable Debug logging to the /wp-content/debug.log file
    define('WP_DEBUG_LOG', true);
    // Disable display of errors and warnings
    define('WP_DEBUG_DISPLAY', false);
    @ini_set('display_errors', 0);

    Then go ahead and try to replicate the error (is this happening when you go to the login page or after hitting the Login button actually?).
    By doing so, a /wp-content/debug.log file should be created. Simply download it, rename it to debug.txt and attach it here in your next reply to see what's going wrong in there.

    Warm regards,

  • Adam Czajczyk

    Hello Derek!

    I used the credentials that you provided me with once again and checked the site. That's entirely my fault and I sincerely apologize for that. I made a small mistake in the child theme's "functions.php" file and that was causing it.

    I didn't noticed that before because I was already logged in into the site and then didn't try to logout and login again. I already fixed that and the site should be fully up and running again.

    I'm really sorry for that!

    Kind regards,