如何在WordPress的短代码子类别

jxct1oxe  于 2022-11-22  发布在  WordPress
关注(0)|答案(1)|浏览(116)

我想在一个简短的代码显示子类别列表。我喜欢如果短代码将像[足球_子类别]
我要全部列出所有子类别

g6baxovj

g6baxovj1#

你可以这样得到它:

  1. add_shortcode('football_subcategory', 'football_subcategory');
  2. function football_subcategory(){
  3. $taxonomies = array(
  4. 'event_cat',
  5. );
  6. $args = array(
  7. 'parent' =>1625, //put your parent category ID
  8. 'hide_empty' => false, // you can make it true and false
  9. // 'child_of' => $parent_term_id,
  10. );
  11. $terms = get_terms($taxonomies, $args);
  12. //add a loop and get all details about category
  13. echo '<pre>';
  14. print_r($terms);
  15. }
展开查看全部

相关问题