Configuration
ConfigurationTranslating the slug for a certain CPT, but not for the others

Translating the slug for a certain CPT, but not for the others

The plugin offers an option in the Settings to translate the post slug, which applies to all custom post types.

Disabling translations for custom post slugs in the Settings
Disabling translations for custom post slugs in the Settings

If you want to translate the slug for a certain custom post type, but not for the others, you can do that via 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 the CPTs for which you want to translate the slug
      $translateSlugForCTPs = [
        'my-custom-post-type',
      ];
 
      /** @var string */
      $customPostType = $variables['customPostType'];
      $variables['updateSlug'] = in_array($customPostType, $translateSlugForCTPs);
    }
    return $variables;
  },
  10,
  2
);