- This topic has 2 replies, 2 voices, and was last updated 3 years, 3 months ago by Leo.
-
AuthorPosts
-
December 26, 2020 at 7:13 am #1594864Randy
Hello,
I have set up a child theme using the instructions on the GP website: https://docs.generatepress.com/article/using-child-theme/All is working well and I’m using several functions in the child theme’s functions.php successfully:
add_action( ‘wp_default_scripts’
add_filter( ‘get_canonical_url’
add_action( ‘wp_head’
add_filter( ‘document_title_parts’
add_filter( ‘generate_sidebar_layout’
add_filter( ‘generate_hook_element_display’
add_filter( ‘the_content’
add_action( ‘transition_post_status’
add_filter( ‘wp_sitemaps_posts_entry’(I list the above in case you have any known issues with how I should use them successfully in a child theme’s functions.php…. but they seem to be working)
The only one that does not work is from Google Tag Manager’s <noscript> tag ( instructions: https://developers.google.com/tag-manager/quickstart ):
do_action( ‘wp_body_open’, function() {
<!– Google Tag Manager (noscript) –>
<noscript><iframe height=’0′ src=’https://www.googletagmanager.com/ns.html?id=GTM-xxxxxx’
style=’display:none;visibility:hidden’ width=’0’/></noscript>
<!– End Google Tag Manager (noscript) –>
})I can get around it by adding that code as a Hook to wp_body_open using your Elements module.
But wondering why that particular one does not work in the child functions.php? And also in general, any guidance on how do I know which functions do and don’t work when placed in the child theme’s functions.php?
Thanks so much!
RandyDecember 26, 2020 at 7:37 am #1594881RandyOops…nevermind on do_action( ‘wp_body_open’
Rookie error: I forgot to include the ?> and <?php
But I do still wonder about the general architecture: Any guidance on how do I know which functions do and don’t work when placed in the child theme’s functions.php?
Also, in general, how does the child theme “point” to the parent theme since only the child theme is shown as “Active”. In other words, how do the customizations of layout, menus, etc that area set in the inactive parent them get automatically used by the active child theme?
I know about the template directive in the style.css of the child theme… but what about everything else that is set in the parent theme since the parent them is not the active theme but its setup is still be used. I’d like to understand how that relationship gets established technically. Hope that makes sense.
December 26, 2020 at 5:03 pm #1595211LeoStaffCustomer SupportAny guidance on how do I know which functions do and don’t work when placed in the child theme’s functions.php?
There isn’t a guideline for this.
You should only add the function you know what it’s doing so that when it’s not working, you would know.
As for how a child theme work, maybe an article like this would help:
https://codeable.io/what-is-a-child-theme-wordpress/Child themes isn’t a theme-specific feature so there should be lots of resources online that explains them.
-
AuthorPosts
- You must be logged in to reply to this topic.