функция since 3.0.0

add_post_type_support()

Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.

Сигнатура

add_post_type_support( string $post_type, string|array $feature, mixed $args )

Описание

Все возможности ядра напрямую связаны с функциональной областью экрана редактирования, например с редактором или метабоксом. К возможностям относятся: ‘title’, ‘editor’, ‘comments’, ‘revisions’, ‘trackbacks’, ‘author’, ‘excerpt’, ‘page-attributes’, ‘thumbnail’, ‘custom-fields’ и ‘post-formats’.
Кроме того, возможность ‘revisions’ определяет, будет ли тип записи хранить редакции, возможность ‘autosave’ определяет, будет ли тип записи автосохраняться, а возможность ‘comments’ определяет, будет ли на экране редактирования отображаться количество комментариев.
Вместе с возможностью можно также передать третий необязательный параметр, чтобы предоставить дополнительную информацию о её поддержке.
Пример использования:
add_post_type_support( 'my_post_type', 'comments' );
add_post_type_support( 'my_post_type', array(
'author', 'excerpt',
) );
add_post_type_support( 'my_post_type', 'my_feature', array(
'field' => 'value',
) );

Оригинал (английский)

All core features are directly associated with a functional area of the edit screen, such as the editor or a meta box. Features include: ‘title’, ‘editor’, ‘comments’, ‘revisions’, ‘trackbacks’, ‘author’, ‘excerpt’, ‘page-attributes’, ‘thumbnail’, ‘custom-fields’, and ‘post-formats’.

Additionally, the ‘revisions’ feature dictates whether the post type will store revisions, the ‘autosave’ feature dictates whether the post type will be autosaved, and the ‘comments’ feature dictates whether the comments count will show on the edit screen.

A third, optional parameter can also be passed along with a feature to provide additional information about supporting that feature.

Example usage:

add_post_type_support( 'my_post_type', 'comments' );
add_post_type_support( 'my_post_type', array(
    'author', 'excerpt',
) );
add_post_type_support( 'my_post_type', 'my_feature', array(
    'field' => 'value',
) );

Параметры

$post_type string обязательный
Тип записи, для которого добавляется возможность.
$feature string|array обязательный
Добавляемая возможность; принимает массив строк-возможностей или одну строку.
$args mixed необязательный
Необязательные дополнительные аргументы, передаваемые вместе с некоторыми возможностями.

Исходный код

wp-includes/post.php:2287

function add_post_type_support( $post_type, $feature, ...$args ) {
	global $_wp_post_type_features;

	$features = (array) $feature;
	foreach ( $features as $feature ) {
		if ( $args ) {
			$_wp_post_type_features[ $post_type ][ $feature ] = $args;
		} else {
			$_wp_post_type_features[ $post_type ][ $feature ] = true;
		}
	}
}

История изменений

ВерсияОписание
5.3.0 Formalized the existing and already documented ...$args parameter by adding it to the function signature.
3.0.0 Introduced.

Что будем искать? Например,Продвижение

Этот сайт использует куки-файлы. Оставаясь на сайте, Вы соглашаетесь на их использование. Для получения дополнительной информации, пожалуйста, ознакомьтесь с политикой в отношении персональных данных.