【问题标题】:Displaying User custom field in wordpress (ACF)在 wordpress (ACF) 中显示用户自定义字段
【发布时间】:2021-07-30 11:05:54
【问题描述】:

我在用户中创建了一个自定义字段。我想显示用户的一些详细信息。字段显示在用户中,但如果我编写一些内容并使用此方法调用字段:

the_field('user_description');

它没有显示作者存档页面中的内容。任何帮助将不胜感激:)

【问题讨论】:

    标签: php html wordpress wordpress-theming advanced-custom-fields


    【解决方案1】:

    对于用户选项,您需要为the_field 使用第二个参数。第二个参数需要以user_ 开头并以用户ID 结尾。因此,要从当前用户那里检索一个选项,您可以这样做:

    ?php the_field('field_name', 'user_' . get_current_user_id()); ?>
    

    【讨论】:

      猜你喜欢
      • 2017-02-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-20
      • 2021-10-06
      • 1970-01-01
      • 2021-04-03
      • 1970-01-01
      • 2021-04-12
      相关资源
      最近更新 更多