【问题标题】:Wordpress: Pass variable set from post editor to templateWordpress:将变量集从帖子编辑器传递到模板
【发布时间】:2017-11-21 04:56:19
【问题描述】:

是否可以从我的文本编辑器中设置一个可以传递模板代码的变量值?

【问题讨论】:

  • 请详细说明您要执行的操作并添加您尝试过的代码。
  • 您只需要在您的页面上使用自定义字段,然后您就可以轻松访问它们。更多信息:codex.wordpress.org/Custom_Fields
  • @VincentDecaux 你能把这个作为答案发布吗?这是正确的。

标签: php wordpress wordpress-theming


【解决方案1】:

您只需要在您的页面上使用自定义字段,然后您就可以轻松访问它们。

更多信息:https://codex.wordpress.org/Custom_Fields

在您的模板中访问:

 $custom = get_post_meta(get_the_ID(), $keyField);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-09
    • 2023-03-24
    • 1970-01-01
    • 2016-10-04
    • 2016-10-10
    • 2021-01-15
    • 2019-09-12
    相关资源
    最近更新 更多