Created
June 15, 2017 11:22
-
-
Save shangdev/0544a1d100b33cfc30517224dcdb03be to your computer and use it in GitHub Desktop.
wp:获取分类目录
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1: get_terms | |
$args = array( | |
'taxonomy' => 'product_cat', | |
'hierarchical' => 1, | |
'show_option_none' => '', | |
'hide_empty' => 0, | |
'include' => '17,18,19,20', | |
'orderby' => 'term_id', | |
'order' => 'ASC' | |
); | |
$items = get_terms( $args ); | |
2: wp_list_categories | |
$args=array( | |
'orderby' => 'name', | |
'order' => 'ASC', | |
'title_li' => sprintf('<h4 class="top-cat"><a href="%s">%s</a></h4>', $url, $title), | |
'hide_empty' => 0, | |
'dpath' => 2, | |
'child_of' => $term_id, | |
'taxonomy' => 'product_cat' | |
); | |
wp_list_categories( $args ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment