admin管理员组

文章数量:1313006

I am attempting to create section of my website footer that has link li of terms from a parent for a custom taxonomy I created.

function add_custom_taxonomies() {
  // Add new "producttype" taxonomy to products
  register_taxonomy('producttype', 'product', array(
    // Hierarchical taxonomy (like categories)
    'hierarchical' => true,
    // This array of options controls the labels displayed in the WordPress Admin UI
    'labels' => array(
      'name' => _x( 'Producttypes', 'taxonomy general name' ),
      'singular_name' => _x( 'Producttype', 'taxonomy singular name' ),
      'search_items' =>  __( 'Search Producttypes' ),
      'all_items' => __( 'All Producttypes' ),
      'parent_item' => __( 'Parent Producttype' ),
      'parent_item_colon' => __( 'Parent Producttype:' ),
      'edit_item' => __( 'Edit Producttype' ),
      'update_item' => __( 'Update Producttype' ),
      'add_new_item' => __( 'Add New Producttype' ),
      'new_item_name' => __( 'New Producttype Name' ),
      'menu_name' => __( 'Product Type' ),
    ),
    // Control the slugs used for this taxonomy
    'rewrite' => array(
      'slug' => 'Producttype', // This controls the base slug that will display before each term
      'with_front' => false, // Don't display the category base before "/locations/"
      'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
    ),
  ));
}
add_action( 'init', 'add_custom_taxonomies', 0 );

I have a parent that i created for the taxonomy "producttype" called "Type" I would like to get only those child terms under the parent term "Type" and display them as a link. I created the parent term in the wordpress dashboard manually.

I am attempting to create section of my website footer that has link li of terms from a parent for a custom taxonomy I created.

function add_custom_taxonomies() {
  // Add new "producttype" taxonomy to products
  register_taxonomy('producttype', 'product', array(
    // Hierarchical taxonomy (like categories)
    'hierarchical' => true,
    // This array of options controls the labels displayed in the WordPress Admin UI
    'labels' => array(
      'name' => _x( 'Producttypes', 'taxonomy general name' ),
      'singular_name' => _x( 'Producttype', 'taxonomy singular name' ),
      'search_items' =>  __( 'Search Producttypes' ),
      'all_items' => __( 'All Producttypes' ),
      'parent_item' => __( 'Parent Producttype' ),
      'parent_item_colon' => __( 'Parent Producttype:' ),
      'edit_item' => __( 'Edit Producttype' ),
      'update_item' => __( 'Update Producttype' ),
      'add_new_item' => __( 'Add New Producttype' ),
      'new_item_name' => __( 'New Producttype Name' ),
      'menu_name' => __( 'Product Type' ),
    ),
    // Control the slugs used for this taxonomy
    'rewrite' => array(
      'slug' => 'Producttype', // This controls the base slug that will display before each term
      'with_front' => false, // Don't display the category base before "/locations/"
      'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
    ),
  ));
}
add_action( 'init', 'add_custom_taxonomies', 0 );

I have a parent that i created for the taxonomy "producttype" called "Type" I would like to get only those child terms under the parent term "Type" and display them as a link. I created the parent term in the wordpress dashboard manually.

Share Improve this question asked Feb 13, 2015 at 17:03 steamfunksteamfunk 6453 gold badges13 silver badges26 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

get_term_children() should be able to do just that. The example in the link looks good.

本文标签: Getting List of child terms from custom taxonomy parent