Support » Plugin: Zone Manager (Zoninator) » [Plugin: Zone Manager (Zoninator)] Add Specific Custom Post Types

  • Zoninator 0.2 has improved support for custom post types. However you need to do something to add specific custom post types. Please let me know if this is the right approach. I’d add the following to something like the theme functions.php to enable public custom post types in zoninator:

    function mf_add_zoninator_post_types () {
    
    global $zoninator;
    
            $available_post_types = array_values(get_post_types(array('public' => true, '_builtin' => false), 'names'));
            $zoninator->default_post_types = array_merge($zoninator->default_post_types, $available_post_types);
    
    }
    add_action('zoninator_pre_init', 'mf_add_zoninator_post_types');

    http://wordpress.org/extend/plugins/zoninator/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Mohammad Jangda

    (@batmoo)

    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.

    Plugin Author Mohammad Jangda

    (@batmoo)

    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?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Zone Manager (Zoninator)] Add Specific Custom Post Types’ is closed to new replies.