Wordpress 从类别列表中获取类别
我现在使用wp_list_categories函数来获取子类别。喜欢写Wordpress 从类别列表中获取类别,wordpress,categories,Wordpress,Categories,我现在使用wp_list_categories函数来获取子类别。喜欢写 $featured_catlist_list = wp_list_categories('title_li=&child_of=' . $term_id .'&echo=0&taxonomy='.$taxonomy_name.'&show_count=0&hide_empty=1&pad_counts=0&show_option_none=&orderby=n
$featured_catlist_list = wp_list_categories('title_li=&child_of=' . $term_id .'&echo=0&taxonomy='.$taxonomy_name.'&show_count=0&hide_empty=1&pad_counts=0&show_option_none=&orderby=name&order=ASC');
现在我必须得到类别名称和url。这样我就可以在任何地方使用它。我可以在选项列表中使用它。与任何一个选择任何类别url重定向到该子类别一样。要使用类别生成选择,可以使用以下选项:
<?php
$cats = get_categories();
if ( $cats ): ?>
<select>
<?php foreach ( $cats as $cat ): ?>
<option value="<?php echo get_category_link( $cat->term_id ); ?>"><?php echo $cat->name; ?></option>
<?php endforeach; ?>
</select>
<?php endif;
?>