apply_filters( 'wpml_element_link', int $element_id, string $element_type, string $link_text, array $optional_parameters, string $anchor, bool $echo, bool $return_original_if_missing )
- 유형
- filter
- 카테고리
- 현지화된 콘텐츠 가져오기
- WPML 버전
- 3.2
설명
현재 언어로 된 글 유형 링크 또는 택소노미 용어 링크를 반환합니다.
* 참고: 개발자가 HTML 출력을 더 완벽하게 제어할 수 있도록 요소의 링크를 가져오는 다른 방법도 있습니다.
WordPress는 이를 위해 get_permalink(), get_term_link() 등과 같은 여러 함수를 제공합니다.
글 유형이나 용어 ID를 매개변수로 요구하는 함수를 사용할 계획이라면 wpml_object_id 필터를 살펴보는 것이 좋습니다.
인수
- $element_id
- (int) (필수) 링크할 글 유형(post, page, attachment, 사용자 정의 글 유형) 또는 택소노미 항목(tag, category, 사용자 정의 분류체계)의 ID입니다.
- $element_type
- (string) (선택) 링크할 요소의 유형입니다. ‘post’, ‘page’, ‘attachment’, '{custom post}', ‘tag’, ‘category’, '{custom taxonomy}' 중 하나일 수 있습니다. 기본값은 ‘post’입니다.
- $link_text
- (string) (선택) 링크 텍스트입니다. 기본값은 요소의 이름입니다.
- $optional_parameters
- (array) (선택) 링크에 대한 인수입니다.
- $anchor
- (string) (선택) 링크의 앵커입니다.
- $echo
- (bool) (선택) 현지화된 링크를 반환하려면 0|false를, 출력하려면 1|true를 사용합니다. 기본값은 true입니다.
- $return_original_if_missing
- (bool) (선택) true로 설정하면 항상 값을 반환합니다(번역이 없는 경우 원본 값). 기본값은 TRUE입니다.
사용 예시
예제
//produces: <a href="/hello-world/">Hello World!</a> apply_filters( 'wpml_element_link', 1 ); //produces: <a href="/sample-page/">Custom link text for the sample page</a> apply_filters( 'wpml_element_link', 2, 'page', __( 'Custom link text for the sample page' ) ); //produces: <a href="/sample-page/?category=foo&bar=baz">Sample Page</a> apply_filters( 'wpml_element_link', 2, 'page', '', array( 'category'=>'foo', 'bar'=>'baz' ) ); //produces: <a href="/sample-page/#contact">Sample Page</a> apply_filters( 'wpml_element_link', 2, 'page', '', '', 'contact' ); //produces: <a href="/category/uncategorized/">Uncategorized</a> apply_filters( 'wpml_element_link', 1, 'category' ); //produces: <a href="/ko/?attachment_id=25">'Attachment image title</a> apply_filters( 'wpml_element_link', 25, 'attachment', __( 'Attachment image title' ) );
관련 훅
wpml_media_url, wpml_media_id, force_suppress_filters, wpml_get_translated_slug, wpml_home_url, wpml_translate_single_string, wpml_translate_string, wpml_elements_without_translations, wpml_permalink, wpml_unfiltered_admin_string