简体   繁体   中英

I cannot get the category id

Here is the script

$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>

Am I using this correctly $cat->ID . Please help.

just try

 parent = '{$category_id}' ORDER 

also use of mysql_* is deprecated so use the pdo or mysqli instead. My personal suggestion is pdo Here is the good tutorial

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM