Все таки пришлось использовать ACF. Использовал доку
https://www.advancedcustomfields.com/resources/cus... // Adds a custom rule type.
add_filter( 'acf/location/rule_types', function( $choices ){
$choices[ __("Other",'acf') ]['wc_prod_attr'] = 'WC Product Attribute';
return $choices;
} );
//Add custom operator
add_filter('acf/location/rule_operators', 'acf_location_rules_operators');
function acf_location_rules_operators( $choices ) {
$choices['start_with'] = 'Starts with';
return $choices;
}
// Adds custom rule values.
add_filter( 'acf/location/rule_values/wc_prod_attr', function( $choices ){
$choices['pa_'] = "pa_";
return $choices;
} );
// Matching the custom rule.
add_filter( 'acf/location/rule_match/wc_prod_attr', function( $match, $rule, $options ){
if ( isset( $options['taxonomy'] ) ) {
if ('start_with' === $rule['operator']){
$match = substr($options['taxonomy'], 0, strlen($rule['value'])) === $rule['value'];
}
}
return $match;
}, 10, 3 );
if( function_exists('acf_add_local_field_group') ) {
acf_add_local_field_group(array(
'key' => 'group_5bdf16f6a992f',
'title' => 'Расширенные настройки атрибута',
'fields' => array(
array(
'key' => 'field_5bdf16fc51f9b',
'label' => 'Заголовок в архиве',
'name' => 'Расширенный заголовок',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
),
'location' => array(
array(
array(
'param' => 'wc_prod_attr',
'operator' => 'start_with',
'value' => 'pa_',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => 1,
'description' => '',
));
}