WP HOOKS
filtrod 4.4.0

register_post_type_args

Args 2Plik wp-includes/class-wp-post-type.phpDokumentacja WP ↗

Opis

Modyfikuje argumenty rejestracji typu treści — pozwala zmieniać typy rejestrowane przez inne wtyczki.

Przykład użycia

add_filter( 'register_post_type_args', ... )php
add_filter( 'register_post_type_args', 'wpdocs_modify_cpt_args', 10, 2 );

function wpdocs_modify_cpt_args( $args, $post_type ) {
	if ( 'book' === $post_type ) {
		$args['show_in_rest'] = true;
	}

	return $args;
}

Parametry

ParametrTypOpis
$argsarrayArray of arguments for registering a post type. See the register_post_type() function for accepted arguments.
$post_typestringPost type key.

Wywołanie

Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'register_post_type_args', 'twoja_funkcja', 10, 2 );

function twoja_funkcja($param_1, $param_2) {
	// Twój kod
}

Popularne w tej kategorii