Hi fellows
I have a function which add a suffix to {post_title} depending of an url parameter. (ie. www.mysite./en/artists-studios/?shz_dept%5B%5D=cher-18-en)
I use it on a archive page as this: “Artists’ studios {echo:shz_get_departement_name_by_query_vars(label)}”. This page has also filters select.
At this time, the {echo:shz_get_departement_name_by_query_vars(label)} does not get the new category name on filter change, even if the url parameter has changed.
It’s work fine if I open a new window directly with the url parameter or if I click on a link having the url parameter.
I guess there is something to do regarding the ajax request but I don’t know where to look or what is missing in my function.
Thanks a lot for your help.
function shz_get_departement_name_by_query_vars( $key ) {
// Retrieves from $_REQUEST (GET + POST) or $key
$departement_input = $_REQUEST["shz_dept"] ?? $key ?? '';
// Handles array cases (shz_dept[] in the URL or in the POST request)
$departement_slug = sanitize_text_field(
is_array($departement_input) ? ($departement_input[0] ?? '') : $departement_input
);
if (!empty($departement_slug)) {
$category = get_term_by('slug', $departement_slug, 'category');
if ($category && !is_wp_error($category)) {
return ' - ' . $category->name;
}
}
return '';
}