自定义分类不适用于前端WooCommerce

时间:2017-07-20 作者:Vasim Shaikh

我为woocommerce产品创建了一个自定义分类法。

function add_hunts_type(){
 // Car Hunts
    $cHunt_labels = array(
        \'name\'              => __( \'Hunts\', \'pixar\' ),
        \'singular_name\'     => __( \'Hunt\', \'pixar\' ),
        \'search_items\'      => __( \'Search Hunts\', \'pixar\' ),
        \'all_items\'         => __( \'All Hunts\', \'pixar\' ),
        \'parent_item\'       => __( \'Parent Hunt\', \'pixar\' ),
        \'parent_item_colon\' => __( \'Parent Hunt:\', \'pixar\' ),
        \'edit_item\'         => __( \'Edit Hunt\', \'pixar\' ),
        \'update_item\'       => __( \'Update Hunt\', \'pixar\' ),
        \'add_new_item\'      => __( \'Add New Hunt\', \'pixar\' ),
        \'new_item_name\'     => __( \'New Hunt\', \'pixar\' ),
        \'menu_name\'         => __( \'Hunts\', \'pixar\' ),
    );
    $cHunt_args = array(
    \'labels\' => $cHunt_labels,
    \'hierarchical\'               => true,
    \'public\'                     => true,
    \'show_ui\'                    => true,
    \'show_admin_column\'          => true,
    \'show_in_nav_menus\'          => true,
    \'show_tagcloud\'              => true,
    \'query_var\' => true,
    \'rewrite\' => array( \'slug\' => \'carhunt\' )
    );
    register_taxonomy( \'car_Hunt\', \'product\', $cHunt_args );
}
add_action( \'init\', \'add_hunts_type\', 0 );

    /* Flush rewrite rules for custom post types. */
add_action( \'after_switch_theme\', \'flush_rewrite_rules\' );
这是工作时,我登录到管理。当想要从前端尝试时,它不起作用。

我已经更改了parmalinks,我已经删除了htaccess并重新注册了它

1 个回复
SO网友:Vasim Shaikh

将已注册的分类添加到对象类型。

function add_hunts_type(){
/*Taxonomy details*/

register_taxonomy_for_object_type( \'carhunt\', \'product\' );

}
add_action( \'init\', \'custom_taxonomy_Hunt\' );

结束

相关推荐