dongtan5558 2014-08-26 13:24
浏览 45
已采纳

Wordpress可重复的metabox组

what code spinet i use in page.php to show data in frontend.

array(
'id'          => $prefix . 'repeat_group',
'type'        => 'group',
'description' => __( 'Generates reusable form entries', 'cmb' ),
'options'     => array(
    'group_title'   => __( 'Entry {#}', 'cmb' ), // since version 1.1.4, {#} gets replaced by row number
    'add_button'    => __( 'Add Another Entry', 'cmb' ),
    'remove_button' => __( 'Remove Entry', 'cmb' ),
    'sortable'      => true, // beta
),
// Fields array works the same, except id's only need to be unique for this group. Prefix is not needed.
'fields'      => array(
    array(
        'name' => 'Entry Title',
        'id'   => 'title',
        'type' => 'text',
        // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
    ),
    array(
        'name' => 'Description',
        'description' => 'Write a short description for this entry',
        'id'   => 'description',
        'type' => 'textarea_small',
    ),
    array(
        'name' => 'Entry Image',
        'id'   => 'image',
        'type' => 'file',
    ),
    array(
        'name' => 'Image Caption',
        'id'   => 'image_caption',
        'type' => 'text',
    ),
),

),

above code taken from:

https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/wiki/Field-Types#group

I did not find any way how i can put it in page.php and show data in front end page.

Thank for help

  • 写回答

2条回答 默认 最新

  • drxm5014 2014-08-26 13:29
    关注

    I think the easiest way to have repeatable metaboxes in the WordPress admin, is to use ACF (http://www.advancedcustomfields.com/) with the repeater field (http://www.advancedcustomfields.com/add-ons/repeater-field/)

    it gives a really nice end product, its easy to use/implement, it has good support, and can be bundled with any theme/plugin as long as you follow the instructions for doing so.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?