Get Product LAST category ID on single_product.php
Wondering if some kind soul out there can help. I’ve tried numerous things, but can’t seem to figure it out.
I need a way to reliably get the
sub/child category ID of a product as a variable. This is on my single_product PHP template page.
I have used this on my category grid page, which works, but it does not work on the single product page:
<?php $category_id = wpsc_category_id(); $getsubs = "SELECT term_id FROM wp_term_taxonomy WHERE taxonomy = 'wpsc_product_category' AND parent = '".$category_id."'"; $subcats = mysql_query($getsubs); $num_subcats = mysql_num_rows($subcats); ?>
and then run the results through and get the values…
Although the above doesn’t help in determining what the last child category is (other than ordering the results) and also as far as I can tell wpsc_category_id() does not seem to work on the single product template.
Can anyone help? I’m really struggling with this.
- The topic ‘Get Product LAST category ID on single_product.php’ is closed to new replies.