부모 카테고리 이름 만 표시하고 싶지 않으며 어떤 제품이나 게시물에도 사용되지 않은 도 표시하고 싶습니다. 부모 맞춤 카테고리 목록 만 있으면됩니다.상위 맞춤 분류 분류 이름 만 표시 하시겠습니까?
은 내가 get_terms, wp_list_categories 기능뿐만 아니라
이 내 코드는이 아이를 보여주는 시도합니다.
<?php
require_once('connection.php');
$taxonomy = 'product_cat';
$orderby = 'parent';
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 0; // 1 for yes, 0 for no
$hierarchical = 0; // 1 for yes, 0 for no
$title = '';
$empty = 0;
$args = array(
'taxonomy' => $taxonomy,
'orderby' => $orderby,
'show_count' => $show_count,
'pad_counts' => $pad_counts,
'childless' => false,
'child_of' => 0,
'title_li' => $title,
'hide_empty' => $empty,
'hierarchical'=>1
//'hierarchical=0&depth=1'
);
$rrr=wp_list_categories($args);
print_r($rrr);
?>
자녀를 표시하고 있지만 상위 카테고리 이름 만 필요합니다.
난 Product_cat은 woocommerce 카테고리이다 사용 제가 get_terms 함께 사용될 때 그것은 널 을 배열 소정있다. 나는이 방법처럼 사용할하지만 product_cat는 get_terms
<?php
$parent_cat_arg = array('hide_empty' => false, 'parent' => 0);
$parent_cat = get_terms('product_cat',$parent_cat_arg);
foreach ($parent_cat as $catVal) {
/*some code*/
}
?>
또한 내가 필요한 설명이 첨부 이미지보기 작동하지 않습니다.
당신이 시도해 봤어입니다 설정보십시오? – Milap
네, 해보았습니다. –