Отображение в админке
Включаем отображение произвольных полей в админке

Создания нового поля

Выбор уже существующего

Вывод произвольного поля WordPress
Произвольное поле это массив.
Чтобы вывести первое/единственное значение массива:
$value = get_post_meta( 76, 'key_1', true ); //> значение 1
Выводим подзаголовок
if( $product_subtitle = get_post_meta( get_the_ID(), 'product_subtitle', true ) ) {
echo "<div class=\"product__subtitle\">$product_subtitle</div>";
}
Добавить поддержку произвольных полей в теме
add_post_type_support
Удалить поддержку произвольных полей
remove_post_type_support
Используется в теме The7 в файле dt-the7/inc/theme-setup.php
if ( ! function_exists( 'presscore_turn_off_custom_fields_meta' ) ) :
/**
* Removes support of custom-fields for pages and posts.
*
* @since 3.0.0
*/
function presscore_turn_off_custom_fields_meta() {
/**
* Custom fields significantly increases db load because of theme heavily uses meta fields. It's a simplest way to reduce db load.
*/
remove_post_type_support( 'post', 'custom-fields' );
remove_post_type_support( 'page', 'custom-fields' );
}
add_action( 'init', 'presscore_turn_off_custom_fields_meta' );
endif;
Чтобы всё-таки включить поддержку произвольных полей, нужно в дочерней теме просто объявить пустую функцию
function presscore_turn_off_custom_fields_meta() {}