我无法获得类别ID

时间:2012-10-20 05:26:44

标签: php wordpress

这是脚本

$category_id = $cat->ID; /* <-- can get the id */
$getsubs = "SELECT term_id FROM wp_term_taxonomy 
WHERE taxonomy = 'wpsc_product_category' AND parent = '".$category_id."' 
ORDER BY term_id ASC";
$subcats = mysql_query($getsubs);
$num_rows = mysql_num_rows($subcats);
wpsc_start_category_query(array('parent_category_id'=>$category_id, 'show_thumbnails'=> 1)); ?>
<li>
<a href="<?php wpsc_print_category_url();?>" title="<?php wpsc_print_category_name();?>">
<?php wpsc_print_category_image(); ?>
<?php //wpsc_print_category_name();?>
<?php //wpsc_print_category_name();?>
</a>
</li>
<?php wpsc_end_category_query(); ?>
<div style="clear:both;"></div>

我是否正确使用此$cat->ID。请帮忙。

1 个答案:

答案 0 :(得分:0)

试试

 parent = '{$category_id}' ORDER 

也不推荐使用mysql_*,因此请改用pdomysqli。我的个人建议是pdo Here is the good tutorial