是否可以更改自定义分类管理界面的内容

时间:2019-09-24 13:23:27

标签: wordpress custom-wordpress-pages

我需要更改为woocommerce产品创建的自定义分类法的管理界面的内容。

TL:DR- 我有一个自定义分类法,我想为其显示自定义模板文件。它当前加载在“类别”中,但这不是我在该页面上需要的。


我目前正在按原样注册我的分类法:

public function add_user_specific_pricing_taxonomy() {
        $args = array( 
            'labels'                     => array(
                'name'                      => esc_html__( 'User Specific Pricing', 'Taxonomy General Name', $this->plugin_name ),
                'singular_name'             => esc_html__( 'User Specific Price', 'Taxonomy Singular Name', $this->plugin_name ),
                'menu_name'                 => esc_html__( 'User Specific Pricing', $this->plugin_name ),
            ),
            'hierarchical'               => true,
            'has_archive'                => true,
            'public'                     => true,
            'show_ui'                    => true,
            'show_admin_column'          => true,
            'show_in_nav_menus'          => true,
            'show_tagcloud'              => true,
            'show_in_rest'               => true,
        );
        register_taxonomy("product_user_specific_pricing", 'product', $args );
        register_taxonomy_for_object_type( 'product_user_specific_pricing', 'product' );
    }

add_action( 'init', 'add_user_specific_pricing_taxonomy', 0 );

然后我尝试在主题中添加一个模板文件,命名为: taxonomy-product_user_specific_pricing.php

这没有任何帮助。然后,我尝试从插件本身添加它,在这里我通过过滤注册了此自定义分类法:

public function custom_taxonomy_template( $template ) {
        if (is_tax('product_user_specific_pricing')) {
            $template = plugin_dir_path( __FILE__ ) . 'templates/taxonomy-product_user_specific_pricing.php';
            return $template;
        }
    }

add_filter( 'template_include', 'custom_taxonomy_template', 0 );

但这似乎也没有帮助。我目前被困在这里。

非常感谢您的帮助!

0 个答案:

没有答案