//-> Busca com filtro avançado
function funcaoParaShortcode(){
?>
<form method="get" action="<?php echo home_url( "https://stackoverflow.com/" ); ?>" style="background-color: #f9f9f9; border-radius: 4px; padding: 20px;">
<input type="text" value="" name="s" id="s" placeholder="Digite algo ou deixe em branco" style="max-width:300px;min-width: 300px;"/>
<?php
$args = array(
'show_option_none' => __( 'Selecione uma categoria', 'textdomain' ),
'show_count' => 1,
'orderby' => 'name',
'hierarchical' => '1',
'exclude' => '1',
'hide_empty' => '1',
'echo' => 0,
);
?>
<?php $select = wp_dropdown_categories( $args ); ?>
<?php $replace = "<select$1 style="height: 35px;">"; ?>
<?php $select = preg_replace( '#<select([^>]*)>#', $replace, $select ); ?>
<?php echo $select; ?>
<select name="year" style="height: 35px;">
<option value="">Selecione um ano</option>
<?php foreach( range(2022,2010) as $_year ) : ?> //Quero um help aqui, buscar todos os anos
<option><?php echo $_year; ?></option>
<?php endforeach; ?>
</select>
<button type="submit" id="searchsubmit" style="height: 35px;margin-top:-1px;"><i class="fa fa-search"></i> Filtrar e buscar</button>
</form>
<?php
}
add_shortcode('busca-avancada', 'funcaoParaShortcode');
#Use este shortcode em seu html: [busca-avancada]
.