I am trying to get all the Custom Post Types Registered either by theme or plugin, but no method is working.
$postargs = array(
'public' => true,
'_builtin' => false
);
$postoutput = 'names';
$postoperator = 'and';
$post_types = get_post_types( $postargs, 'names', 'and' );
/// Main Loop Start
foreach ($post_types as $post_type){
//and then i want to Get all the Custom Taxonomies for those post types in a loop
$taxonomies = get_object_taxonomies('$post_type', 'objects');
// Loop
foreach ($taxonomies as $taxonomy){
// Do Stuff with taxonomy
} // Loop
} /// Main Loop Ends
But the problem is only WordPress Defaults Post Types are showing up if i do
'_builtin' => true
- post
- page
- attachment
attachment
This is the Code to Registered Post Type I don't get any post type, i currently have 8 Custom Post Types in the theme. the post is registered with this code...
$args = array(
'labels' => array(
'name' => __( 'Faq', 'yit' ),
'singular_name' => __( 'Faq', 'yit' ),
'plural_name' => __( 'Faqs', 'yit' ),
'item_name_sing' => __( 'Faq', 'yit' ),
'item_name_plur' => __( 'Faqs', 'yit' ),
'add_new' => __( 'Add New Faq', 'yit' ),
'add_new_item' => __( 'Add New Faq', 'yit' ),
'edit' => __( 'Edit', 'yit' ),
'edit_item' => __( 'Edit Faq', 'yit' ),
'new_item' => __( 'New Faq', 'yit' ),
'view' => __( 'View Faq', 'yit' ),
'view_item' => __( 'View Faq', 'yit' ),
'search_items' => __( 'Search Faqs', 'yit' ),
'not_found' => __( 'No Faqs', 'yit' ),
'not_found_in_trash' => __( 'No Faqs in the Trash', 'yit' ),
),
'hierarchical' => false,
'public' => true,
//'menu_position' => 30,
//'icon_menu' => ,
'has_archive' => 'faq',
'rewrite' => array( 'slug' => apply_filters( 'yit_faqs_rewrite', 'faq' ) ),
'supports' => array( 'title', 'editor', 'cats'),
'description' => "Faq"
);
register_post_type('faq', $args);
get_post_types()
with no arguments?'_builtin' => false
otherwise you will only be showing the built in post types (Quote Codex: Iftrue
, will return WordPress default post types. Usefalse
to return only custom post types.)