WordPress.org

Ready to get started?Download WordPress

Forums

get_post_types doesn't work in plugin (2 posts)

  1. 2046
    Member
    Posted 1 year ago #

    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

  2. 2046
    Member
    Posted 1 year ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic