dongping9475 2017-07-20 16:13
浏览 61
已采纳

如何从cmb2选项页面显示数据?

I have created a repeatable field with CMB2, and created a normal field. This is the function of https://pastebin.com/XUQgkvbi

If you use foreach for repeatable using a post or page then you can show data as: https://pastebin.com/C35vWGDs

And Call normal field without repeatable, then

<?php $ entries = get_post_meta (get_the_ID (), 'yourprefix_group_demo', true); ?>

<?php echo $ entries; ?>

also work.

But the problem is, I do not want to use the above function on any page or post. I want to use it in the Options Page. The above Function option has been added to the option page, but I can not do the data show of those files in any way. I've tried get_post_meta () and get_option () with two functions, but in no way can I show data from the option page. How can I get the data from the above fields (option page) to the show in the frontend? Please help with a little bit.

  • 写回答

1条回答 默认 最新

  • drnf593779 2017-07-21 16:13
    关注

    I got solution, The options are stored in a single option field. You would loop through the news-section groups with something like this:

    $settings = get_option( 'repeatable-news-options.php', array() );
    
    if ( ! empty( $settings['news-section'] ) ) {
        foreach ( $settings['news-section'] as $section ) {
            echo $section['title'] . '<br/>';
        }
    }
    

    that link https://wordpress.org/support/topic/how-to-display-data-from-cmb2-option-page/

    problem solved.

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

报告相同问题?

悬赏问题

  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab