WPML
apply_filters( 'wpml_element_has_translations', mixed $empty_value, int $element_id, string $element_type )
类型
filter
WPML 版本
3.2

说明

根据文章类型或分类法项是否已翻译,返回 TRUE 或 FALSE。

参数

$empty_value
(mixed) (必填) 这通常是过滤器将要修改的值。我们在这里不进行任何过滤,因此将其设置为 NULL。这是为了让过滤器函数实际接收完整的参数列表。
$element_id
(int) (必填) 要检索其信息的元素 ID。对于分类法项使用 term_id,对于文章类型使用 post_id。
$element_type
(string) (必填) ID 所属的元素类型。可以是文章类型:post、page、attachment、nav_menu_item、{custom post key},或分类法:category、post_tag、nav_menu、{custom taxonomy key}。

使用示例

示例
//$is_translated will be TRUE if the custom post is translated and FALSE if it is not translated
$is_translated = apply_filters( 'wpml_element_has_translations', NULL, 61, 'book' )

wpml_element_translation_type, wpml_is_translated_post_type, wpml_is_translated_taxonomy, wpml_master_post_from_duplicate, wpml_post_duplicates

所有 6 个 查找内容的翻译状态 钩子 →