I am currently working on a WordPress website, where the chosen shopping platform is WooCommerce.
I want to create a series of Template files, to be called within the content-product-single.php
file, which contains Maths calculations. For some reason, the Maths calculations only seems to work when placed in the functions.php
rather than my assigned Template files. It was suggested that the way in which I was using the get_template_part
tags could be incorrect. Here is the original code I was using:
<?php
if (is_product_category('category-name')) {
get_template_part( 'templates/template-a' );
}
elseif (is_single('product-slug')) {
get_template_part( 'templates/template-b' );
}
elseif (is_single('product-slug')) {
get_template_part( 'templates/template-c' );
}
?>
If anyone notices any errors in my above code, then please do let me know as that could be the issue but for the time being, I think that my Maths coding may only work within a functions
file.
For organisation purposes, is there a way I can create multiple functions.php
files or would this be bad practice? I have tried functions-template-file-name.php
and placed this in the root of the theme but still the Maths does not work.