自定义帖子类型多语言与 Polylang



我有这个问题,我现在不知道如何解决。我们有一个多语言的wordpress页面,这要归功于Polylang插件。除了其他插件的自定义帖子类型外,一切都很好。使用此自定义帖子类型创建的帖子会加载基本语言(英语)的内容,但每当我们更改语言时,它就会停止工作。它不加载内容

我注册了这样的帖子类型:

register_post_type( 'placement', 
array(
'labels' => array(
'name' => __( 'Placementy' ),
'singular_name' => __( 'Placement' )
),
'public' => true,
'menu_icon' => 'dashicons-welcome-write-blog'
)
);

我试过了,在我的函数中注册帖子类型.php而不是插件主文件,仍然是一样的......其他自定义帖子类型运行良好,并且它们的注册方式相同。我还尝试在我的 wordpress 主题中为自定义帖子类型创建模板,而不是使用插件中的模板,但它也失败了......真的不知道为什么它不起作用。尤其是当其他一切正常时。更改后还清除了缓存。在开发人员和本地环境中选中已更改。什么会导致这种行为?

在函数中.php

add_filter('pll_get_post_types', 'add_cpt_to_pll', 10, 2);
function add_cpt_to_pll($post_types, $hide) {
if ($hide)
// hides 'my_cpt' from the list of custom post types in Polylang settings
unset($post_types['my_cpt']);
else
// enables language and translation management for 'my_cpt'
$post_types['my_cpt'] = 'my_cpt';
return $post_types;
}

了解更多详情 https://polylang.wordpress.com/documentation/documentation-for-developers/filter-reference/

最新更新