dsa80833 2017-04-27 21:13
浏览 62
已采纳

自定义字段现在使用Wordpress显示在我的新页面上?

I created a new template for a page.

<?php
    /**
     * Template Name: Sponsors For Homepage
     */
    ?>

    <html>
    <body>
    <?php get_header('sponsor'); ?>

    <div class='divone'>
      <?php the_content(); ?>
    </div>

    <div class='divtwo'>
    <?php sponser_advertisement(); ?>
    </div>

    </section>
    </body>
    </html>

And I added a new custom field for the template. Using the Advanced Custom Fields plugin 4.4.8enter image description here

I made sure that the field would show on the correct template: enter image description here

The fields showed up on my template page

enter image description here

For some reason the field value "This is the new field" does not not show up when I preview the page in my browser.

Thanks in advance.

Suggestions?

  • 写回答

1条回答 默认 最新

  • douquanzhan0315 2017-04-27 21:19
    关注

    This is the wrong way to display the custom field value.

    If you want to display custom field values in your template, using Advanced custom fields plugin you have to use functions like these:

    <?php the_field('field_name'); ?>
    

    or

    <?php echo get_field('field_name'); ?>
    

    you can find full documentation on working with ACF values in here: ACF Documentation

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作