В настоящее время я пытаюсь добавить статическую страницу в свой тип сообщения.Причина этого:
- я бы хотел, чтобы мой клиент мог изменить изображение объекта на мой archive-our_classes.php, а также использовать блок призыва к действию, который я создал с помощьюНастраиваемые поля.
Я посмотрел этот ответ здесь и не могу заставить мой код работать - пожалуйста, помогите!(Примечание: я не изменил их заметки из проектов на "наши_классы")
Добавить статическую страницу в настройки чтения для пользовательского типа записи
add_action( 'admin_init', function () {
$id = 'our_classes';
// add_settings_field( $id, $title, $callback, $page, $section = 'default', $args = array() )
add_settings_field( $id, 'Our Classes Page:', 'settings_field_our_classes', 'reading', 'default', array(
'label_for' => 'field-' . $id, // A unique ID for the field. enter code hereOptional.
'class' => 'row-' . $id, // A unique class for the TR. Optional.
) );
} );
/**
* Renders the custom "Projects page" field.
*
* @param array $args
*/
function settings_field_our_classes( $args ) {
$id = 'our_classes';
wp_dropdown_pages( array(
'name' => $id,
'show_option_none' => '— Select —',
'option_none_value' => '0',
'selected' => get_option( $id ),
) );
}
/**
* Adds page_for_projects to the white-listed options, which are automatically
* updated by WordPress.
*
* @param array $options
*/
add_filter( 'whitelist_options', function ( $options ) {
$options['reading'][] = 'our_classes';
return $options;
} );
Я былюбовь помощь о том, как заставить это работать!Заранее спасибо!