How to Fix Common Twenty Nineteen Child Theme Issues
Content
Creating a child theme for the Twenty Nineteen theme is a fundamental practice for making customizations that persist through updates. However, several common issues can arise during setup that prevent the child theme from working correctly. This guide covers the most frequent problems and their solutions, based on community discussions.
Common Problem: CSS Changes Not Taking Effect
A frequently reported issue is that CSS rules added to a Twenty Nineteen child theme's style.css file do not override the parent theme's styles. This often manifests when a user adds a simple rule, like changing an h1 color to green, but sees no change on the front end.
Why This Happens
The primary cause is an incorrect method of enqueuing the parent theme's stylesheet. Many tutorials recommend using the @import rule in the child theme's CSS, which is an outdated method that can cause load order issues and specificity problems. The modern, WordPress-recommended method is to use the wp_enqueue_style() function in the child theme's functions.php file.
Solution: Properly Enqueue Styles
Instead of using @import, add the following code to your child theme's functions.php file. This ensures the parent style is loaded before the child style, allowing your modifications to override the parent theme correctly.
<?php
function my_theme_enqueue_styles() {
$parent_style = 'twentynineteen-style';
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' );
?>
The handle name ('child-style') is arbitrary and does not need to match your folder name; it is simply a unique identifier for the stylesheet.
Common Problem: Logo Disappears When Child Theme is Activated
Some users have reported that activating a child theme, even an empty one, causes the site's logo to vanish.
Why This Happens
This is typically a caching issue. When you switch themes, your browser or any active caching plugins may serve an old, cached version of the site that doesn't reflect the new theme's setup. The logo is often added through the WordPress Customizer, and its display is controlled by theme support functions that need to be properly inherited.
Solution: Clear Your Cache
The first and most crucial step is to clear all caching layers:
- Browser Cache: Hard refresh your browser (Ctrl+F5 or Cmd+Shift+R).
- Plugin Cache: Clear any cache generated by plugins like W3 Total Cache or WP Super Cache.
- Server Cache: If you use a hosting provider with server-level caching (e.g., Varnish), clear that cache through your host's control panel or by contacting support.
After clearing the cache, revisit your site. The logo should reappear. If the issue was purely cache-related, no code changes are needed.
Common Problem: Unable to Dequeue a Parent Theme Script
Developers sometimes need to remove a parent theme's JavaScript file, such as touch-keyboard-navigation.js, to resolve conflicts. Simply calling wp_dequeue_script() may not work if not done with the correct hook or priority.
Why This Happens
The script must be dequeued on the same hook where it was enqueued, and often after it has been enqueued. Using a hook that fires too early, like wp_print_scripts, or an incorrect priority can cause the function to fail.
Solution: Dequeue with the Correct Hook and Priority
Use the wp_enqueue_scripts hook with a late priority (a high number) to ensure the parent script has already been enqueued before you try to remove it. You must also use the correct script handle, which can often be found by inspecting the parent theme's functions.php file.
<?php
function project_dequeue_unnecessary_scripts() {
wp_dequeue_script( 'twentynineteen-touch-navigation' ); // Use the correct handle
wp_deregister_script( 'twentynineteen-touch-navigation' );
}
add_action( 'wp_enqueue_scripts', 'project_dequeue_unnecessary_scripts', 999 );
?>
Conclusion
Most issues with Twenty Nineteen child themes stem from a few common sources: improper style enqueuing, caching, or incorrect hooks for modifying scripts. By following the solutions outlined above, you can resolve these problems and build a stable foundation for your customizations. For further reading, the official WordPress documentation on child themes is an excellent resource.
Related Support Threads Support
-
Uncaught Error: Call to undefined function get_header()https://wordpress.org/support/topic/uncaught-error-call-to-undefined-function-get_header/
-
Twenty nineteen custom template paginationhttps://wordpress.org/support/topic/twenty-nineteen-custom-template-pagination/
-
dequeue parent theme script in child themehttps://wordpress.org/support/topic/dequeue-parent-theme-script-in-child-theme/
-
Move Logo Above Titlehttps://wordpress.org/support/topic/move-logo-above-title/
-
Extending TwentyNineteen_SVG_Icons class in Child Themehttps://wordpress.org/support/topic/extending-twentynineteen_svg_icons-class-in-child-theme/
-
Custom Bugs that Walk Javascript to run on Twenty Nineteen Themehttps://wordpress.org/support/topic/custom-bugs-that-walk-javascript-to-run-on-twenty-nineteen-theme-2/
-
Proper Enqueuing of Child Theme; Removing Query Stringshttps://wordpress.org/support/topic/proper-enqueuing-of-child-theme-removing-query-strings/
-
Install live demo as template/baseline?https://wordpress.org/support/topic/install-live-demo-as-template-baseline/
-
Using custom page templates in Twenty Nineteenhttps://wordpress.org/support/topic/using-custom-page-templates-in-twenty-nineteen/
-
Jquery not loaded?https://wordpress.org/support/topic/jquery-not-loaded-2/
-
Why does my child theme CSS get called twice?https://wordpress.org/support/topic/why-does-my-child-theme-css-get-called-twice/
-
How to add my own “error 404” page to Twenty Nineteen?https://wordpress.org/support/topic/how-to-add-my-own-error-404-page-to-twenty-nineteen/
-
How to Improve speed of Twenty Nineteenhttps://wordpress.org/support/topic/how-to-improve-speed-of-twenty-nineteen/
-
Designing the wordpress 2019 themehttps://wordpress.org/support/topic/designing-the-wordpress-2019-theme/
-
Twenty nineteen theme – child theme edithttps://wordpress.org/support/topic/twenty-nineteen-theme-child-theme-edit/
-
2017 theme is the only one working when loaded all others shows 404 error messgehttps://wordpress.org/support/topic/2017-theme-is-the-only-one-working-when-loaded-all-others-shows-404-error-messge/
-
Modified twenty-nineteen language files.https://wordpress.org/support/topic/modified-twenty-nineteen-language-files/
-
How to remove Excerpt if left empty?https://wordpress.org/support/topic/how-to-remove-excerpt-if-left-empty/
-
jquery.js not loaded when child theme enabled.https://wordpress.org/support/topic/jquery-js-not-loaded-when-child-theme-enabled/
-
Twenty Nineteen Custom Templatehttps://wordpress.org/support/topic/twenty-nineteen-custom-template/
-
npm install fails with latest Twenty Nineteenhttps://wordpress.org/support/topic/npm-install-fails-with-latest-twenty-nineteen/
-
NO FOLLOW NO INDEX TAGhttps://wordpress.org/support/topic/no-follow-no-index-tag/
-
I’m using the twenty nineteen theme.https://wordpress.org/support/topic/im-using-the-twenty-nineteen-theme/
-
What is the effect of theme update.https://wordpress.org/support/topic/what-is-the-effect-of-theme-update/
-
main tag cannot and must not be child of sectionhttps://wordpress.org/support/topic/tag-cannot-and-must-not-be-child-of/
-
Sidebar in Twenty Nineteenhttps://wordpress.org/support/topic/sidebar-in-twenty-nineteen/
-
Child Themehttps://wordpress.org/support/topic/child-theme-272/
-
pinit.js, embedding and Pinteresthttps://wordpress.org/support/topic/pinit-js-embedding-and-pinterest/
-
function_existshttps://wordpress.org/support/topic/function_exists-3/
-
Full Text vs Excerptshttps://wordpress.org/support/topic/full-text-vs-excerpts/
-
child themehttps://wordpress.org/support/topic/child-theme-297/
-
Twentynineteen & Pluginshttps://wordpress.org/support/topic/twentynineteen-plugins/
-
Creating a Child Themehttps://wordpress.org/support/topic/creating-a-child-theme-30/
-
Switching from old wordpress Coraline Theme to Twenty Nineteenhttps://wordpress.org/support/topic/switching-from-old-wordpress-coraline-theme-to-twenty-nineteen/
-
Twenty Nineteen default themehttps://wordpress.org/support/topic/twenty-nineteen-default-theme/
-
Unable to find theme editor for twenty nineteenhttps://wordpress.org/support/topic/unable-to-find-theme-editor-for-twenty-nineteen/
-
Logo and Descriptiomhttps://wordpress.org/support/topic/logo-and-descriptiom/
-
Why is New Page misbehaving, missing Page Attributeshttps://wordpress.org/support/topic/why-is-new-page-misbehaving-missing-page-attributes-2/
-
Adding/Changing SVG iconshttps://wordpress.org/support/topic/adding-changing-svg-icons/
-
Demo contenthttps://wordpress.org/support/topic/demo-content-39/
-
Twenty Nineteen Website Demo Files?https://wordpress.org/support/topic/twenty-nineteen-website-demo-files/
-
function twentynineteen_discussion_avatars_list()https://wordpress.org/support/topic/function-twentynineteen_discussion_avatars_list/
-
From twenty fourteen to twenty nineteenhttps://wordpress.org/support/topic/from-twenty-fourteen-to-twenty-nineteen/
-
Child theme deleting logohttps://wordpress.org/support/topic/child-theme-deleting-logo/
-
Newsletter widgethttps://wordpress.org/support/topic/newsletter-widget-2/