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 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么