WordPress.org

Support

Support » Plugins and Hacks » get_post_types doesn't work in plugin

get_post_types doesn't work in plugin

  • 2046
    Participant

    @o-o

    Hello,

    I have strange problem here.
    I try to cal the “get_post_types” within the plugin, but it never gives me any registered custom post types.
    here is the code:

    $args_types=array(
    	'public'	=> true, // publicaly visible
    	'_builtin' => false, // only not built in
    );
    //~ get all post types
    $post_types = get_post_types($args_types,'objects');

    when I do the same in the template everything is fine..
    do you know how to fix it.

    thx

Viewing 1 replies (of 1 total)
  • 2046
    Participant

    @o-o

    It works within the widget class as well, not in the plugin. I
    guess it is because it runs before all the types are registered.

    In that case how to postpone the plugin execution after all the custom post_types are registered?

Viewing 1 replies (of 1 total)
  • The topic ‘get_post_types doesn't work in plugin’ is closed to new replies.