Replies: 0
Hello my website is: Passn’ Time so I was adding functions to the original Storefront theme functions.php and once it did some security updates, everything was then deleted throughout the file that I custom added. So I looked into building a Storefront child theme and so far it’s working good for simple edits but I am unsure on how to add functions to the child themes functions.php since I already have some code in there. Right now I have the code from Codex-Wordpress to map it back to the original theme and load it:
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
?>
Now I need to add a meta slide with full width, a function/action to remove the footer font, and a action to remove the related products on the product page. Here is that code:
add_action( 'init', 'child_theme_init' );
function child_theme_init() {
add_action( 'storefront_before_content', 'woa_add_full_slider', 5 );
}
function woa_add_full_slider() { ?>
<div id="slider">
<?php echo do_shortcode("[metaslider id=297 percentwidth=100 restrict_to=home]"); ?>
</div>
<?php }
add_action( 'init', 'custom_remove_footer_credit', 10 );
function custom_remove_footer_credit () {
remove_action( 'storefront_footer', 'storefront_credit', 20 );
add_action( 'storefront_footer', 'custom_storefront_credit', 20 );
}
function custom_storefront_credit() {
?>
<div class="site-info">
© <?php echo get_bloginfo( 'name' ) . ' ' . get_the_date( 'Y' ); ?>
</div><!-- .site-info -->
<?php
}
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
Now the problem is, is that I can’t find out how to add this code to the child themes functions.php with the code already there without it messing up and crashing the theme. Right now I have added the custom code to my Storefront parent theme but I want to have it on my child themes functions.php because I know once it updates again, it’ll disappear.
Could somebody PLEASE help me and share some knowledge with me?
- This topic was modified 4 minutes ago by 5pacek.