Using conditional tags in a child theme functions.php file
-
Hi,
My client’s website is using Jigoshop and I need to add some conditional code to the functions.php file to show a link to a size chart only in certain category IDs just above the add to cart button. I’ve copied the code needed into my child theme’s functions.php file as seen below but for some reason the div just won’t show for these categories. I’ve tested the same code using the is_single tag and it works fine but just can’t get it working with category IDs, any help would be appreciated please?
<?php if (!function_exists('jigoshop_simple_add_to_cart')) { function jigoshop_simple_add_to_cart() { global $_product; $availability = $_product->get_availability(); // do not show "add to cart" button if product's price isn't announced if( $_product->get_price() === '') return; ?> <form action="<?php echo esc_url( $_product->add_to_cart_url() ); ?>" class="cart" method="post"> <?php do_action('jigoshop_before_add_to_cart_form_button'); ?> <?php if ( in_category( array( 50,19,18 ) ) ) { echo '<div class="size-chart">Hello</div>'; } ?> <div class="quantity"><input name="quantity" value="1" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div> <button type="submit" class="button-alt"><?php _e('Add to cart', 'jigoshop'); ?></button> <?php do_action('jigoshop_add_to_cart_form'); ?> </form> <?php } } ?>
Many thanks,
Jim Isles
- The topic ‘Using conditional tags in a child theme functions.php file’ is closed to new replies.