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 关于模型导入UNITY的.FBX: Check external application preferences.警告。
  • ¥15 气象网格数据与卫星轨道数据如何匹配
  • ¥100 java ee ssm项目 悬赏,感兴趣直接联系我
  • ¥15 微软账户问题不小心注销了好像
  • ¥15 x264库中预测模式字IPM、运动向量差MVD、量化后的DCT系数的位置
  • ¥15 curl 命令调用正常,程序调用报 java.net.ConnectException: connection refused
  • ¥20 关于web前端如何播放二次加密m3u8视频的问题
  • ¥15 使用百度地图api 位置函数报错?
  • ¥15 metamask如何添加TRON自定义网络