KonfiguracjaTłumaczenie sluga dla określonego CPT, ale nie dla pozostałych
Tłumaczenie sluga dla określonego CPT, ale nie dla pozostałych
Wtyczka oferuje opcję w Ustawieniach umożliwiającą tłumaczenie sluga posta, która dotyczy wszystkich custom post types.

Jeśli chcesz tłumaczyć sluga dla określonego custom post type, ale nie dla pozostałych, możesz to zrobić za pomocą hooka 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') {
// Zdefiniuj CPT, dla których chcesz tłumaczyć sluga
$translateSlugForCTPs = [
'my-custom-post-type',
];
/** @var string */
$customPostType = $variables['customPostType'];
$variables['updateSlug'] = in_array($customPostType, $translateSlugForCTPs);
}
return $variables;
},
10,
2
);