WordPress.org

Ready to get started?Download WordPress

Forums

Zone Manager (Zoninator)
Add Specific Custom Post Types (6 posts)

  1. sqlwiz
    Member
    Posted 2 years ago #

    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/

  2. Mohammad Jangda
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  3. diniscorreia
    Member
    Posted 1 year ago #

    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.

  4. diniscorreia
    Member
    Posted 1 year ago #

    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.

  5. Mohammad Jangda
    Member
    Plugin Author

    Posted 1 year ago #

    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 );
        }
    }
  6. diniscorreia
    Member
    Posted 1 year ago #

    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 :\

  7. kurra
    Member
    Posted 1 year ago #

    Mohammad,

    I also have same issue, can you let us know the fix?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags