WordPress主题名称在主题php文件中,这样做的目的是什么?

标签 wordpress

我构建基本主题已经快一年了,我正在努力尽可能地清理我的风格。但我不知道到哪里去寻找它的作用......

在库布里克主题 php 文件中,例如,您会得到这样的 php 标签...

<?php the_content('<p class="serif">' . __('Read the rest of this entry &raquo;', 'kubrick') . '</p>'); ?>

您会看到主题名称“kubrick”交织在一起。这样做的目的是什么?

你可以在所有主题中看到它,二十十,二十一,等等......但如果我保持不变,我永远不会注意到有什么不同。如果我将其更改为我当前的主题名称,这有什么好处?

谁能帮我解答一下吗?或者为我指明正确的方向?

谢谢 乔什

最佳答案

这是“主题文本域”,通常用于本地化。您可以通过阅读 gettext filter reference 了解更多信息。需要注意的是,文本域不需要与您的主题名称相同。只要与使用 load_theme_textdomain 加载的内容一致,您就可以将其制作为任何您想要的内容。 。这只是惯例,使其与您的主题名称相同。最后,至于为什么您应该在此处添加域,引用了一篇名为 How to localize WordPress themes and plugins with GetText 的文章。 :

Have you noticed the 2nd argument in the GetText calls? It’s an optional argument that tells GetText what the scope (domain) of the texts is. If supplied, this GetText will return the translations only from the dictionary that you supply with that domain name. Although optional, specifying the translation domain is highly recommended. Without it, GetText might return a different translation, if the same string also appears in a different plugin, or in WordPress.

关于WordPress主题名称在主题php文件中,这样做的目的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8388764/

相关文章:

php - 显示来自多个自定义帖子类型的特定类别的帖子

wordpress - 如何设置永久链接以在 wordpress 中使用父帖子获取所有子自定义帖子?

php - 以 html 形式动态创建 mailchimp 组

wordpress - Woocommerce:获取所有 sku 产品的列表

html - 将 gzip 压缩的 css 文件导入 html 标题?

wordpress - Algolia - WordPress - 编辑帖子模板(图片)

facebook - w3c 验证器显示 Facebook 打开图错误

javascript - 使用 php 循环 WordPress 的响应式框布局

php - 在 Woocommerce 3 中访问订单项目保护数据

css - 顶部栏菜单在移动 View 中不可见