Playing with Custom Post Type UI.
To get the list of all post type
get_post_types();
Output
Array
(
[post] => post
[page] => page
[attachment] => attachment
[revision] => revision
[nav_menu_item] => nav_menu_item
[readers-corners] => readers-corners
[food-and-travel] => food-and-travel
[music-entertainment] => music-entertainment
)
--------------------------------------------------------
--------------------------------------------------------
To get the list of all custom post type (which is created by Custom Post UI Plugin)
print_r($options = get_option( 'cptui_post_types' ));
Output:
Array
(
[readers-corners] => Array
(
[name] => readers-corners
[label] => Readers Corners
[singular_label] => Reader Corner
[description] =>
......
[supports] => Array
(
[0] => title
[1] => editor
......
)
[taxonomies] => Array
(
)
[labels] => Array
(
[menu_name] => Readers Corners
[all_items] => All Readers Corners
[add_new] => Add New
......
)
[custom_supports] =>
)
[food-and-travel] => Array
(
[name] => food-and-travel
[label] => Foods And Travels
[singular_label] => Food And Travel
[description] =>
......
[supports] => Array
(
[0] => title
......
)
[taxonomies] => Array
(
[0] => foods-and-travels-category
)
[labels] => Array
(
[menu_name] => Foods And Travels
[all_items] => All Foods And Travels
......
)
[custom_supports] =>
)
)
>>>>>>>>>>>>>>>>
foreach ($options as $key => $value) {
echo $value['label'];
echo '<br/>';
}
Output:
Foods And Travels Category
Music Categories
Nation And World Category
--------------------------------------------------------
--------------------------------------------------------
To get the list of taxonomy related to a post_type
$taxonomy_names = get_object_taxonomies('music-entertainment');
print_r($taxonomy_names);
Output:
Array
(
[0] => music-categories
)
--------------------------------------------------------
--------------------------------------------------------
get all term list depending upon the taxonomy
$taxonomies = array(
'music-categories',
);
$args = array(
'orderby' => 'name',
'order' => 'ASC',
'parent' => 26, // remove this line if you want to see all the list of term, use 0- for all top level or
parent terms and give any term id to see there childs
'hide_empty' => FALSE,
);
Output:
Array
(
[0] => stdClass Object
(
[term_id] => 27
[name] => Bengali
[slug] => bengali-poem-of-the-week
[term_group] => 0
[term_taxonomy_id] => 27
[taxonomy] => music-categories
[description] =>
[parent] => 26
[count] => 1
)
[1] => stdClass Object
(
......
)
[2] => stdClass Object
(
.....
)
)