我正在为wordpress项目构建自定义帖子类型,但是我不明白为什么在互联网上的某些示例中为什么可以找到这样的内容:
register_post_type('omb_prodotti',
array(
'labels' => array(
'name' => __( 'customposttype' ),
'singular_name' => __( 'customposttype' )
)
“ __(”的作用是什么?它与翻译有关吗?不能这样写吗?
register_post_type('omb_prodotti',
array(
'labels' => array(
'name' => 'customposttype',
'singular_name' => 'customposttype'
)
抱歉,我是PHP和构建自定义WP主题的初学者。
非常感谢你。
无法__
在搜索引擎中进行搜索,但是wordpress double underscore
我在WordPress文档中找到了答案:
描述
从translate()中检索翻译后的字符串。
用法
<?php $translated_text = __( $text, $domain ); ?>
来源。
如您所写,这是翻译内容的功能。关于您的问题,如果您不调用该__()
函数,则该字符串不会被翻译,只会显示customposttype
。使用__('customposttype')
,它将加载一个翻译,它可能是一个相关的字符串。您必须查看代码以找到相应的字符串。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句