filtrod 2.7.0
get_search_form
Opis
Podmienia domyślny formularz wyszukiwania.
Przykład użycia
add_filter( 'get_search_form', ... )php
add_filter( 'get_search_form', 'wpdocs_search_form' );
function wpdocs_search_form( $form ) {
return '<form role="search" method="get" action="' . esc_url( home_url( '/' ) ) . '">'
. '<input type="search" name="s" value="' . esc_attr( get_search_query() ) . '">'
. '<button type="submit">' . esc_html__( 'Szukaj', 'wpdocs' ) . '</button>'
. '</form>';
}
add_filter( 'get_search_form', 'wpdocs_search_form' );
function wpdocs_search_form( $form ) {
return '<form role="search" method="get" action="' . esc_url( home_url( '/' ) ) . '">'
. '<input type="search" name="s" value="' . esc_attr( get_search_query() ) . '">'
. '<button type="submit">' . esc_html__( 'Szukaj', 'wpdocs' ) . '</button>'
. '</form>';
}Parametry
| Parametr | Typ | Opis |
|---|---|---|
$form | string | The search form HTML output. |
$args | array | The array of arguments for building the search form. See get_search_form() for information on accepted arguments. |
Wywołanie
Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'get_search_form', 'twoja_funkcja', 10, 2 );
function twoja_funkcja($param_1, $param_2) {
// Twój kod
}
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'get_search_form', 'twoja_funkcja', 10, 2 );
function twoja_funkcja($param_1, $param_2) {
// Twój kod
}Popularne w tej kategorii