ConfiguraciónTraducir el slug para un CPT concreto, pero no para los demás
Traducir el slug para un CPT concreto, pero no para los demás
El plugin ofrece una opción en los Ajustes para traducir el slug del post, que se aplica a todos los custom post types.

Si quieres traducir el slug para un custom post type concreto, pero no para los demás, puedes hacerlo mediante el 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') {
// Define los CPTs para los que quieres traducir el slug
$translateSlugForCTPs = [
'my-custom-post-type',
];
/** @var string */
$customPostType = $variables['customPostType'];
$variables['updateSlug'] = in_array($customPostType, $translateSlugForCTPs);
}
return $variables;
},
10,
2
);