wordpress - woocommerce how to get current category -


i accessing archive-products.php on woocommerce display products (like normal process in woocommerce).

on page of archive-products.php have added sidebar product categories shop has (with or without products). have used following code so:

$taxonomy = 'product_cat'; $orderby = 'id'; $show_count = 0;      // 1 yes, 0 no $pad_counts = 0;      // 1 yes, 0 no $hierarchical = 1;      // 1 yes, 0 no $title = '<h2>' . _x('our products', 'mfarma') . '</h2>'; $hide_empty = 0;  $args = array(     'taxonomy' => $taxonomy,     'orderby' => $orderby,     'order' => 'asc',     'show_count' => $show_count,     'pad_counts' => $pad_counts,     'hierarchical' => $hierarchical,     'title_li' => $title,     'hide_empty' => $hide_empty ); ?>  <ul>     <?php wp_list_categories($args); ?> </ul> 

now left side of page has above sidebar , right 1 has products. in each product category have added small description html format want show when user has clicked category. according woocommerce when go specific category (in case, http://localhost/product-category/mycategory) still archive-products.php.

i trying term_id link clicked, loop (and global $post) points me first product of list instead of category need. if category has 0 products, can't term id. how term id archive-products.php?

found answer else applies question.

add_action('woocommerce_archive_description', 'woocommerce_category_description', 2);  function woocommerce_category_description() {     if (is_product_category()) {         global $wp_query;         $cat = $wp_query->get_queried_object();         echo "cat is:".print_r($cat,true); // category needed.     } } 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -