WPML에서 하나의 사용자 지정 게시 유형 slug를 변환할 수 없습니다.
저는 WPML 포럼에서 이 문제를 제기했지만, 여기 있는 누군가가 도움을 줄 수 있기를 바랍니다.
커스텀 포스트 타입의 slug를 번역하려고 합니다.
영어 URL은 http://brigade-electronics.com/nl/products/backeye360/ 입니다.
변환된 URL은 http://brigade-electronics.com/nl/producten/backeye360/이어야 합니다.
대신 translate slug 옵션을 활성화한 후 URL로 이동하면 404 오류가 발생합니다.
문제를 복제하는 단계:
- [ WPML ]-> [ Translation options ]을 클릭합니다.
- 커스텀 포스트의 변환(WPML 문자열 변환 사용)을 유효하게 합니다.
- [ Custom posts settings ](같은 페이지)에서 [translate](번역) 체크박스를 클릭합니다.
- 언어별 번역 슬러그 추가
- [저장]을 클릭합니다.
- 프런트 엔드로 이동하여 제품 섹션에만 404 오류가 표시됩니다.
트러블 슈팅 페이지의 모든 옵션을 실행하여 데이터베이스를 클리어했습니다.
이것은 제품 섹션의 특정 페이지에만 적용되는 것 같습니다.여기서 가장 이상한 부분은 '제품'이라는 용어가 영어로 되어 있기 때문에 번역된 슬러그가 있든 없든 URL은 그대로인데, 이 페이지에는 404 에러가 표시됩니다.
그 외의 커스텀 포스트 타입은 문제없이 동작하는 것도 주의할 필요가 있습니다.
사용자 지정 게시 유형이 표준 방식으로 등록되었습니다.
function register_products_post_type() {
$labels = array(
'name' => __( 'Products', '' ),
'singular_name' => __( 'Product', '' )
);
$args = array(
'label' => __( 'Products', '' ),
'labels' => $labels,
'description' => '',
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_rest' => false,
'rest_base' => '',
'has_archive' => false,
'show_in_menu' => true,
'exclude_from_search' => false,
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => true,
'rewrite' => array( 'slug' => 'products', 'with_front' => false ),
'query_var' => true,
'menu_position' => 6,
'menu_icon' => 'dashicons-cart',
'supports' => array( 'title', 'thumbnail', 'page-attributes' )
);
register_post_type( 'products', $args );
}
add_action( 'init', 'register_products_post_type' );
아래 답변에 따라 위 코드는 다음 주소로 업데이트되었습니다.
add_action( 'init', 'create_post_type');
function create_post_type() {
$labels = array(
'name' => _x( 'Products', 'general name of the post type' ),
'singular_name' => _x( 'Products', 'name for one object of this post type' ),
);
$args = array(
'labels' => $labels, // An array that defines the different labels assigned to the custom post type
'public' => true, // To show the custom post type on the WordPress dashboard
'supports' => array( 'title', 'thumbnail', 'page-attributes' ),
'has_archive' => true, //Enables the custom post type archive at
'hierarchical' => true, //Enables the custom post type to have a hierarchy
'rewrite' => array( 'slug' => _x('products', 'URL slug')),
);
register_post_type( 'products', $args );
}
slug의 새로운 번역이 'String Translation' 섹션에 표시되며, 이러한 문자열을 업데이트할 때 동일한 404 오류가 발생합니다.이것들을 영어로 남겨두면 상품 섹션은 문제없이 작동합니다.
감사해요.
이거 드셔보세요
add_action( 'init', 'create_post_type');
function create_post_type() {
$labels = array(
'name' => _x( 'Products', 'general name of the post type' ),
'singular_name' => _x( 'Products', 'name for one object of this post type' ),
);
$args = array(
'labels' => $labels, // An array that defines the different labels assigned to the custom post type
'public' => true, // To show the custom post type on the WordPress dashboard
'supports' => array( 'title', 'thumbnail', 'page-attributes' ),
'has_archive' => true, //Enables the custom post type archive at
'hierarchical' => true, //Enables the custom post type to have a hierarchy
'rewrite' => array( _x('slug' => 'products'), 'with_front' => false ),
);
register_post_type( 'products', $args );
}
다시 쓰기 규칙은 지워놨어?
[ Settings ]> [ Permalinks ]으로 이동하여 새로 고칩니다.
주의: 플러그인 내부에 포스트 타입을 등록하는 경우 활성화 및 비활성화 후크에서 flush_rewrite_rules()를 호출합니다(아래 '액티베이션 시 플래시 리라이트' 참조).flash_rewrite_rules()를 사용하지 않을 경우 수동으로 [설정(Settings)]> [퍼멀링크(Permalinks)]으로 이동하여 퍼멀링크 구조를 새로 고쳐야 커스텀 투고 유형이 올바른 구조를 표시할 수 있습니다.
출처 : https://codex.wordpress.org/Function_Reference/register_post_type
언급URL : https://stackoverflow.com/questions/44410257/unable-to-translate-one-custom-post-type-slug-in-wpml
'programing' 카테고리의 다른 글
AngularJS : 디렉티브에서 글로벌이벤트에 바인드 하는 최선의 방법 (0) | 2023.03.21 |
---|---|
jQuery Ajax의 Bool 매개 변수가 PHP에서 리터럴 문자열 "false"/"true"로 수신되었습니다. (0) | 2023.03.21 |
js 내의 다른 파일을 포함하여 mongodb에서 javascript 스크립트(.js 파일)를 실행합니다. (0) | 2023.03.21 |
ASP에서의 JSON 시리얼화/디시리얼화넷코어 (0) | 2023.03.21 |
Ajax : 성공이 0으로 표시되는 이유는 무엇입니까? (0) | 2023.03.21 |