Declare Global Variables for Customization
-
Hello,
I need to show some icons in my product page. They depend on product attributes (they are like a score).
I’ve made a function to convert the value of the attribute ($value = 1) into icons (with a for()). This is stored in functions.php and called in the template.
The thing is that obviously this is not the smartest way to do it because of memory. I assume that if for every product page, WP has to run the same function over and over…I should save it globally, but there is a lot of advice against this on the internet.
What’s the way to go about this? Thanks!
Hi,
You can use your function for each product without worries, it should not impact your website speed.
Regards