filtrod 4.4.0
register_post_type_args
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;
}
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
| Parametr | Typ | Opis |
|---|---|---|
$args | array | Array of arguments for registering a post type. See the register_post_type() function for accepted arguments. |
$post_type | string | Post 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
}
// 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