When I call get_post_types() in a plugin the output is registering only the basic set of post types. Here is the output:

array(5) { ["post"]=> string(4) "post" ["page"]=> string(4) "page" ["attachment"]=> string(10) "attachment" ["revision"]=> string(8) "revision" ["nav_menu_item"]=> string(13) "nav_menu_item" }

In this wordpress theme, however, I have registered a custom post type called 'artist', but it is not showing up. If, however, I call get_post_types() in the index.php file it does how the registered posts:

array(8) { ["post"]=> string(4) "post" ["page"]=> string(4) "page" ["attachment"]=> string(10) "attachment" ["revision"]=> string(8) "revision" ["nav_menu_item"]=> string(13) "nav_menu_item" ["acf"]=> string(3) "acf" ["artist"]=> string(6) "artist" ["release"]=> string(7) "release" }

Does anyone know why this is happening and how to get around the problem?

  • Where and when do you call get_post_types()? – kaiser May 22 '13 at 23:40

You have to wait with your call until the theme has registered its post type (it really should not do that anyway):

add_action( 'after_setup_theme', 'list_post_types', 20 );

function list_post_types()
    var_export( get_post_types() );
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.