Failing at adding child theme functions
-
Hi,
Just got a child theme sorted which has the following functions.php file:
<?php add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); } ?>
I want to add the following function to this file (it works out how many units of a product are still available);
**/Product Stock Quantity Check For Course Calendar Page/** add_shortcode('product_stock', 'product_stock'); function product_stock( $atts ) { if ( ! $atts['id'] ) { return ''; } $product = get_product($atts['id']); return (int) $product->stock; }
How do I add this to the functions.php file??
I’ve tried this (below) and it just breaks the site.
<?php add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); } **/Product Stock Quantity Check For Course Calendar Page/** add_shortcode('product_stock', 'product_stock'); function product_stock( $atts ) { if ( ! $atts['id'] ) { return ''; } $product = get_product($atts['id']); return (int) $product->stock; } ?>
Anyone know what I should be doing here?
Thanks!!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Failing at adding child theme functions’ is closed to new replies.