Для этого я бы использовал фильтр 'the_meta_key'. у вас есть несколько вариантов, и, конечно же, вы можете их комбинировать.
управления, что скрыть с помощью CSS
add_filter('the_meta_key' , 'class_custom_fields', 10, 3);
function classes_custom_fields($string, $key, $value){
return str_replace('<li>','<li class="' . str_replace(' ', '-', $key). '">',$string);
}
<style>
ul.post-meta li.total_sales{
display:none;
}
</style>
управления, что скрывать с помощью PHP & CSS
add_filter('the_meta_key' , 'hide_custom_fields', 10, 3);
function hide_custom_fields($string, $key, $value){
$hide_keys = array(
'total_sales'
);
if(in_array(strtolower($key), $hide_keys)){
return str_replace('<li>','<li class="hide">',$string);
}
return $string;
}
<style>
.hide{
display:none;
}
</style>
управления, что дисплей с PHP
add_filter('the_meta_key' , 'allowed_custom_fields', 10, 3);
function allowed_custom_fields($string, $key, $value){
$allowed_keys = array(
'attribute one',
);
if(in_array(strtolower($key), $allowed_keys)){
return $string;
}
}
управления, что не отображать с PHP
add_filter('the_meta_key' , 'disallowed_custom_fields', 10, 3);
function disallowed_custom_fields($string, $key, $value){
$disallowed_keys = array(
'total_sales'
);
if(!in_array(strtolower($key), $disallowed_keys)){
return $string;
}
}
Существует важное различие между сокрытием и удалением. –