การกำหนดค่า
การกำหนดค่าแปลสลักสำหรับ CPT บางประเภท แต่ไม่ใช่ทั้งหมด

แปลสลักสำหรับ CPT บางประเภท แต่ไม่ใช่ทั้งหมด

ปลั๊กอินมีตัวเลือกในหน้าการตั้งค่าสำหรับการแปลสลักของโพสต์ ซึ่งใช้งานได้กับ custom post type ทั้งหมด

ปิดการแปลสลักของ custom post ในหน้าการตั้งค่า
ปิดการแปลสลักของ custom post ในหน้าการตั้งค่า

หากต้องการแปลสลักสำหรับ custom post type บางประเภทเท่านั้น แต่ไม่ต้องการแปลประเภทอื่น สามารถทำได้ผ่าน 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
);