I'm trying to get all post types (custom & built_in) but it's only gives me only built_in ones in admin. I can get all of them in root (5 with builtins included) but in admin, i can only get 3.

I throught need a trigger an action or something but i couldn't find it.

    $post_types = get_post_types( array( 'public' => true ), 'name' ); 

More info: I'll use it in reduxframework's config page (in "setSection" function).

PS: I don't want to get post_types with sql query, because i need empty post_types too.

Edit: it is not about just admin.

For reduxframework developers; you can't use any function which uses the init action flag. For reference: https://github.com/ReduxFramework/redux-framework/issues/1181

  • 'name' is not a valid value, it is 'names' or 'objects'. Can you try? – cybmeta Mar 7 '15 at 8:22
  • Stil same. I was getting object, with 'names' get just names :) I thing it's must be an trigger or something to do this. Just getting core post types :/ Thanks for reply @cybmeta – ahmetertem Mar 7 '15 at 8:39
  • I can not reproduce the issue. Can you verify that the custom post types you are trying to get are public? Are you using get_post_types in a action hook? If so, which one? – cybmeta Mar 7 '15 at 8:48
  • Nope I'm not usin it. I created a post type named "Portfolio". Reduxframework can get it in fields. But in config things, it's not working. I used same arguments with redux. For information: args; public and exclude_from_search – ahmetertem Mar 7 '15 at 9:00
  • You have to be sure to use get_post_types after init event. I can not tell you how to integrate this with Reduxframework (third party software is off-topic here). – cybmeta Mar 7 '15 at 9:19

register_post_type is recommended to be used in init action hook. So, get_post_types should be used in an action after init. Hooking in init with a very high priority, 999 or greater, should also work in almost every situation but it is safer to use a later action hook.


add_action('wp_loaded', function(){
        $post_types = get_post_types( array( 'public' => true ), 'names' ); 

In admin section you can use admin_init, which run after init:

add_action('admin_init', function(){
        $post_types = get_post_types( array( 'public' => true ), 'names' ); 
| 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.