Using has_category to modify template
-
I’m trying to using the has_category function to modify a Woo Commerce template so that products in a specific category are displayed slightly different from others. I don’t know if I’m using the function incorrectly, or if my php syntax is bad (or maybe both).
if (has_category(blue-widget)) { echo "This is a blue widget"; } else { echo "This is not a blue widget"; }
It does seem to recogize the difference in categories because I get different results between blue-widget products and other products. But it doesn’t give the results I expect. In both cases, it prints the “else” statement, and on blue-widgets, it actually breaks part of the page.
Any idea what I’m doing wrong?
- The topic ‘Using has_category to modify template’ is closed to new replies.