Kullancs

cat_ID , 'product_cat' ); $cat_lak_args = array( 'orderby' => 'name', 'order' => 'asc', 'parent' => 36, 'hide_empty' => false, ); $cat_eko_args = array( 'orderby' => 'name', 'order' => 'asc', 'parent' => 41, 'hide_empty' => false, ); $product_categories_lak = get_terms( 'product_cat', $cat_lak_args ); $product_categories_eko = get_terms( 'product_cat', $cat_eko_args ); if ( ! empty( $product_categories_lak ) || ! empty( $product_categories_eko )) { echo '

Válasszon az alábbi kategóriák közül!

'; echo '

Lakossági termékeink:

'; echo '
    '; foreach ( $product_categories_lak as $key => $category ) { printf( '
  • %2$s
  • ', get_term_link( $category ), $category->name ); } echo '
'; echo '

Eko-sect termékeink:

'; echo '
    '; foreach ( $product_categories_eko as $key => $category ) { printf( '
  • %2$s
  • ', get_term_link( $category ), $category->name ); } echo '
'; } } else { $terms_post = get_the_terms( $post->cat_ID , 'product_cat' ); /* Custom function to get the parent category ID */ function wdo_get_product_top_level_category ( $product_id ) { $product_top_category=''; $prod_terms = get_the_terms( $product_id, 'product_cat' ); foreach ($prod_terms as $prod_term) { $product_cat_id = $prod_term->term_id; $product_parent_categories_all_hierachy = get_ancestors( $product_cat_id, 'product_cat' ); $last_parent_cat = array_slice($product_parent_categories_all_hierachy, -1, 1, true); foreach($last_parent_cat as $last_parent_cat_value){ $product_top_category = $last_parent_cat_value; } } return $product_top_category; } // Call above function to get top level category for Product ID $parent_cat_id = wdo_get_product_top_level_category($post->ID); /*****************************************************************/ $cat_args = array( 'orderby' => 'name', 'order' => 'asc', 'parent' => $parent_cat_id, 'hide_empty' => false, ); $product_categories = get_terms( 'product_cat', $cat_args ); if ( ! empty( $product_categories ) ) { /*echo '

Válasszon az alábbi kategóriák közül!

';*/ echo '
    '; foreach ( $product_categories as $key => $category ) { printf( '
  • %2$s
  • ', get_term_link( $category ), $category->name ); } echo '
'; } } ?>
Elem hozzáadva a kosárhoz.
1 elem - 1.430 Ft
1