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!
Related Posts:
- How to enqueue scripts on custom post add/edit pages?
- remove custom post type permalink
- How to change “Draft” string for status of custom post type to “Unavailable”?
- Action hook on Edit custom post type?
- Unregister post type from child theme
- Custom post type save_post action not firing
- How to correctly get post type in a the_title filter
- How to intercept publish post for a custom post type “event”
- Why The Init Hook For Custom Post Types
- flush_rewrite_rules on save_post Does Not Work on First Post Save
- How to show more posts on an archive page?
- With what hook can I address all posts from all custom post types when they are published?
- Make the ‘all’ filter default instead of ‘mine’ in a custom post type
- Dynamically Create Terms in Taxonomy when Custom Post Type is Published. Almost There!
- WordPress Custom Shortcode Conflicting with Media Library
- WordPress custom post action hook
- Custom post type archive sorted and grouped by date in post meta field
- What hook should be used to programmatically create a post only when master post is updated?
- pre get posts changing the query
- How to register custom post types in a plugin?
- Actions that Run on Admin Edit Page Load After Posts Are Queried
- Using pre_get_posts to Filter Posts
- Remove “Get Shortlink” button in admin of custom post type
- update_post_meta() whenever custom post type is updated
- How to get Custom Post ID by adding filter to child theme’s function
- Custom post_type search’s $wp_query->query_vars do not correspond
- Check Title Unique Or Not and If not error message and dont save
- Can’t unregister parent theme’s CPT from my child theme
- Add html to cpt main page / admin edit.php
- register_taxonomy and register_post_type does not work [closed]
- How to: Display ACF [fields] on Custom Post Types Utilising WordPress ‘Hooks’? [closed]
- Custom post type unintentionally called in every page
- Displaying custom taxonomy in the admin list of a custom post type
- Can taxonomies of custom post types be used with category actions?
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- How do I add a custom screen for a custom post type to be called from custom post row action?
- Custom post type suppress transition from future to publish
- Filter Posts from the Main Query
- Using preg_replace to filter custom textarea
- Create new custom post and post category of same name
- Use remove_meta_box conditionally on custom post type
- Include php on a specific page template
- wp_trash_post action hook with custom post type
- How do I amend form data before it is saved for a custom post type
- What do the numbers mean at the end of add_action(‘save_post’)…?
- Running a wordpress action when a custom post type term (taxonomy category) is changed
- Types plugin custom post add_action hooks
- Loading plugin text domain before registering post type
- How can I get some of a posts meta data whilst it is still inserting?
- add_action ‘init’ from inside a class for custom post types
- How to recover the post ID earlier in the WP admin hook action “firing” sequence?
- Using `set_transient()` when saving a custom post type
- Using publish_{custom-post-type} hook for custom post type to update meta doesn’t work
- Post Click Redirect to Custom URL instead of Single Post Page
- publish_post action callback not executed, why?
- How to store additional data that is related to core data
- Keep br tags from stripping
- do action inside a class is not working
- Filter wp_dropdown_categories Per Post Type
- What is the proper way implement a global $wp_rewrite?
- Dynamically change post_parent in every page load?
- Create action running on trashed_post hook to modify post_meta value
- Custom post type functions.php if statement on action
- Mixing custom post type and taxonomy rewrite structures?
- Resolve a custom post type name vs. page permalink conflict (same slug)
- Inconsistent temporary 404s on whole install | PHP error with post-template.php
- Display current taxonomy term when inside custom post type
- Importing old blog with regular posts into new custom post types
- How can I add dropdown widget/box to admin post page?
- Get posts with tag all post types
- Date-based permalinks for Custom Post Type, and custom taxonomy permalinks
- Keyword search limited to specific post type filtered by multiple custom taxonomies?
- get_post_meta returns empty array for terms
- Display as tree terms of taxonomy and custom posts for each term of taxonomy
- Post count by month of taxonmy term
- Showing another posts on Archive custom post type page
- How to order and group custom post type posts by year and month
- First custom field value (out of several) displayed twice after query
- Custom while loop for hierarchical display of a taxonomy
- Grouping of CPTs and taxonomies into menu groups in admin
- Use date in the URL of custom post type
- Why does not this wp_redirect work in is_single()?
- WP_query – Filter by tax_query and meta_query using multiple select
- Display custom tags for custom post listing page
- Confusion about how to use Custom Post Types, Custom Taxonomy or Category?
- Limiting Amount of Posts in a Custom Post Type again
- Get taxonomy name used in a current post
- Custom Post type not Querying in switch_to_blog loop
- CPT remove /blog/ by add new portfolio default /blog/%postname%/
- Search form to find custom meta box generated data
- Taxonomy Grid Archive Help?
- Custom Loop and Standard Blog Loop Issue
- Custom Post Query Combined with Conditional Tags
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Allow admin to determine the order of queries?
- Problems with pagination for a custom post type
- WordPress custom post type odd and even styling [duplicate]
- Add categories to custom post type
- Same slug for Custom Taxonomy archive and CPT archive – Rewrite rule not working
- WordPress post objects in one parent post object