action init hook and get_post_types

Because you calling get_post_types() in functions.php that is excuted before ‘init’ action.
Look this picture http://www.rarst.net/images/wordpress_core_load.png

if you add an echo inside function test

function test(){
    $args = array(
        'public'          => true,
        'publicly_queryable' => true,
        'show_ui'         => true,
        'query_var'       => true,
        'exclude_from_search' => true,
        'hierarchical'    => false,
        'has_archive'     => false,

    ); 

    register_post_type( 'test', $args );

    echo 'HELLO!!';

}
add_action( 'init', 'test' );

print_r(get_post_types()); 

You’ll see before the array of custom fields and then ‘Hello!” string!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)