有没有办法将一个定制贴子类型连接到另一个定制贴子类型的分类?(特定于地点)

时间:2015-06-21 作者:Mike

很想知道是否有人可以提供以下解决方案。。。

我有两种自定义帖子类型:

提供位置(分类法)

  • 业务位置(分类法)
  • 我想按位置对提供和业务进行排序,但不想复制所有位置或向两种自定义帖子类型添加新位置。有没有办法将企业自定义帖子类型链接到“提供位置”分类法?我这样问是因为我不想有重复的位置,除非这是不可能实现的。

  • 1 个回复
    SO网友:Mike

    我不知道我可以为超过1个CPT/post类型注册分类法!

        register_taxonomy( \'location\', array( \'offer\', \'store\' ), array(
            \'label\' => __( \'Location\', \'themeify\' ),
            \'hierarchical\' => true,
            \'labels\' => array(
                \'name\'                          => __( \'Location\', \'themeify\' ),
                \'singular_name\'                 => __( \'Location\', \'themeify\' ),
                \'menu_name\'                     => __( \'Location\', \'themeify\' ),
                \'all_items\'                     => __( \'All Locations\', \'themeify\' ),
                \'edit_item\'                     => __( \'Edit Location\', \'themeify\' ),
                \'view_item\'                     => __( \'View Location\', \'themeify\' ),
                \'update_item\'                   => __( \'Update Location\', \'themeify\' ),
                \'add_new_item\'                  => __( \'Add New Location\', \'themeify\' ),
                \'new_item_name\'                 => __( \'New Location Name\', \'themeify\' ),
                \'parent_item\'                   => __( \'Parent Location\', \'themeify\' ),
                \'parent_item_colon\'             => __( \'Parent Location:\', \'themeify\' ),
                \'search_items\'                  => __( \'Search Locations\', \'themeify\' ),
                \'popular_items\'                 => __( \'Popular Locations\', \'themeify\' ),
                \'separate_items_with_commas\'    => __( \'Separate locations with commas\', \'themeify\' ),
                \'add_or_remove_items\'           => __( \'Add or remove locations\', \'themeify\' ),
                \'choose_from_most_used\'         => __( \'Choose from the most used locations\', \'themeify\' ),
                \'not_found\'                     => __( \'No locations found\', \'themeify\' ),
            )
    
        ) );
    
    我添加了带有自定义post类型“offer”和“store”的数组。

    现在,当我向这个分类法中添加位置时,它在提供和存储中都会更新:)没有位置重复:D

    结束

    相关推荐