You’d be better off using add_post_type_support
:
function mf_add_zoninator_post_types() {
$available_post_types = array_values(get_post_types(array('public' => true, '_builtin' => false), 'names'));
foreach ( $available_post_types as $post_type ) {
add_post_type_support( $post_type, 'zoninator_zones' );
}
}
add_action('zoninator_pre_init', 'mf_add_zoninator_post_types');
Or simply including 'zoninator_zones'
in your supports
arg when registering your post_type.
Hi Mohammad,
I’m trying to achieve the same – I tried both the function you pasted and adding zoninator_zones
in the supports
arg but nothing works.
If you use the function above, the action appears to run before the custom post types are created; if I hook the function to init
I can see my custom post type (when I debug the $available_post_types
), but the custom post types still don’t appear on the search.
Hi Mohammad,
I’m trying to achieve the same – I tried both the function you pasted and adding zoninator_zones
in the supports
arg but nothing works.
If you use the function above, the action appears to run before the custom post types are created; if I hook the function to init
I can see my custom post type (when I debug the $available_post_types
), but the custom post types still don’t appear on the search.
Yeah, it’s a load order issue.
Something like this probably works better:
add_action( 'init', 'my_register_public_post_types_to_zones', 99 ); // init late to make sure zoninator and our custom post types are loaded
function my_register_public_post_types_to_zones() {
$available_post_types = array_values( get_post_types( array( 'public' => true, '_builtin' => false ), 'names' ) );
foreach ( $available_post_types as $post_type ) {
add_post_type_support( $post_type, 'zoninator_zones' );
register_taxonomy_for_object_type( 'zoninator_zones', $post_type );
}
}
I tried changing the priority but it still doesn’t seem to work – only posts are listed on the search.
I also tried using the zoninator_post_init
hook but no luck :\
Mohammad,
I also have same issue, can you let us know the fix?