ConfigurazioneTradurre lo slug per un CPT specifico, ma non per gli altri
Tradurre lo slug per un CPT specifico, ma non per gli altri
Il plugin offre un'opzione nelle Impostazioni per tradurre lo slug del post, che si applica a tutti i custom post type.

Se vuoi tradurre lo slug per un determinato custom post type, ma non per gli altri, puoi farlo tramite l'hook gatompl:query_variables:
add_filter(
'gatompl:query_variables',
/**
* @param array<string, mixed> $variables The variables to pass to the query.
* @return array<string, mixed> The variables to pass to the query.
*/
function (
array $variables,
string $querySlug
): array {
if ($querySlug === 'translate-customposts') {
// Definisci i CPT per i quali vuoi tradurre lo slug
$translateSlugForCTPs = [
'my-custom-post-type',
];
/** @var string */
$customPostType = $variables['customPostType'];
$variables['updateSlug'] = in_array($customPostType, $translateSlugForCTPs);
}
return $variables;
},
10,
2
);