dongwei3866 2017-01-22 13:14
浏览 92
已采纳

用下划线定制的wordpress主题

I'm trying to include a few custom fields I've created in my functions.php file so they're native to the theme I'm working on. However they're not showing up on the edit screens of the posts I've set them to.

I've included the acf plugin in my theme by using this code in my functions.php: include_once('advanced-custom-fields/acf.php');

I also exported the fields to php and copy and pasted the code in the functions.php of my theme. Can anyone tell me what I'm doing wrong?

Below is my exported code

define( 'ACF_LITE', true );

include_once('/advanced-custom-fields/acf.php');

if( function_exists('register_field_group') ):

register_field_group(array (
    'id' => 'acf_about-us',
    'title' => 'About Us',
    'fields' => array (
        array (
            'key' => 'field_586e22820cdf9',
            'label' => 'About Us',
            'name' => 'about_us',
            'type' => 'text',
            'instructions' => 'Enter Title for about us here',
            'required' => 1,
            'default_value' => '',
            'placeholder' => 'Enter Title for about us here',
            'prepend' => '',
            'append' => '',
            'formatting' => 'none',
            'maxlength' => '',
        ),
        array (
            'key' => 'field_586e22f80cdfa',
            'label' => 'Establised At',
            'name' => 'establised_at',
            'type' => 'text',
            'required' => 1,
            'default_value' => '',
            'placeholder' => 'When where you established',
            'prepend' => '',
            'append' => '',
            'formatting' => 'none',
            'maxlength' => '',
        ),
    ),
    'location' => array (
        array (
            array (
                'param' => 'page',
                'operator' => '==',
                'value' => '15',
                'order_no' => 0,
                'group_no' => 0,
            ),
        ),
    ),
    'options' => array (
        'position' => 'normal',
        'layout' => 'default',
        'hide_on_screen' => array (
        ),
    ),
    'menu_order' => 0,
));
register_field_group(array (
    'id' => 'acf_food-menu',
    'title' => 'Food Menu',
    'fields' => array (
        array (
            'key' => 'field_58808cfded5b3',
            'label' => 'Price',
            'name' => 'price',
            'type' => 'text',
            'required' => 1,
            'default_value' => '',
            'placeholder' => '',
            'prepend' => '',
            'append' => '',
            'formatting' => 'html',
            'maxlength' => '',
        ),
        array (
            'key' => 'field_5881f02f46739',
            'label' => 'Currency',
            'name' => 'currency',
            'type' => 'select',
            'required' => 1,
            'choices' => array (
                '$' => '$',
                '&euro' => '€',
            ),
            'default_value' => '',
            'allow_null' => 0,
            'multiple' => 0,
        ),
        array (
            'key' => 'field_5880aceb6427c',
            'label' => 'Food Category',
            'name' => 'food_category',
            'type' => 'checkbox',
            'required' => 1,
            'choices' => array (
                'breakfast' => 'Breakfast',
                'lunch' => 'Lunch',
                'dinner' => 'Dinner',
                'party' => 'Party',
                'drinks' => 'Drinks',
            ),
            'default_value' => 'breakfast : Breakfast',
            'layout' => 'vertical',
        ),
    ),
    'location' => array (
        array (
            array (
                'param' => 'post_type',
                'operator' => '==',
                'value' => 'foodmenu',
                'order_no' => 0,
                'group_no' => 0,
            ),
        ),
    ),
    'options' => array (
        'position' => 'normal',
        'layout' => 'no_box',
        'hide_on_screen' => array (
        ),
    ),
    'menu_order' => 0,
));
register_field_group(array (
    'id' => 'acf_footer-details',
    'title' => 'Footer details',
    'fields' => array (
        array (
            'key' => 'field_5878f731da3ad',
            'label' => 'footer image',
            'name' => 'footer_image',
            'type' => 'image',
            'instructions' => 'Footer Image Goes Here',
            'save_format' => 'object',
            'preview_size' => 'medium',
            'library' => 'all',
        ),
        array (
            'key' => 'field_5878f756da3ae',
            'label' => 'footer content',
            'name' => 'footer_content',
            'type' => 'text',
            'instructions' => 'footer content goes here',
            'default_value' => '',
            'placeholder' => '',
            'prepend' => '',
            'append' => '',
            'formatting' => 'none',
            'maxlength' => '',
        ),
        array (
            'key' => 'field_58794f98697fa',
            'label' => 'Social Icons',
            'name' => '',
            'type' => 'tab',
        ),
        array (
            'key' => 'field_58794d05697f8',
            'label' => 'Facebook Username',
            'name' => 'facebook_username',
            'type' => 'text',
            'instructions' => 'Enter Your Facebook Username Here',
            'default_value' => '',
            'placeholder' => 'ajbeacon',
            'prepend' => '',
            'append' => '',
            'formatting' => 'none',
            'maxlength' => '',
        ),
        array (
            'key' => 'field_58794c93697f7',
            'label' => 'Twitter Username',
            'name' => 'twitter_username',
            'type' => 'text',
            'instructions' => 'Enter Twitter Username Here',
            'default_value' => '',
            'placeholder' => 'ajbeacon',
            'prepend' => '@',
            'append' => '',
            'formatting' => 'none',
            'maxlength' => '',
        ),
        array (
            'key' => 'field_58794d65697f9',
            'label' => 'Google Plus Username',
            'name' => 'google_plus_username',
            'type' => 'text',
            'instructions' => 'Enter Your Google Plus Username Here',
            'default_value' => '',
            'placeholder' => '+ajbeacon',
            'prepend' => '',
            'append' => '',
            'formatting' => 'none',
            'maxlength' => '',
        ),
    ),
    'location' => array (
        array (
            array (
                'param' => 'page',
                'operator' => '==',
                'value' => '15',
                'order_no' => 0,
                'group_no' => 0,
            ),
        ),
    ),
    'options' => array (
        'position' => 'normal',
        'layout' => 'default',
        'hide_on_screen' => array (
        ),
    ),
    'menu_order' => 0,
));
register_field_group(array (
    'id' => 'acf_opening-time',
    'title' => 'Opening Time',
    'fields' => array (
        array (
            'key' => 'field_58795883ae60c',
            'label' => 'Opening Time',
            'name' => '',
            'type' => 'tab',
        ),
        array (
            'key' => 'field_587957a30aecf',
            'label' => 'Breakfast',
            'name' => 'breakfast',
            'type' => 'wysiwyg',
            'required' => 1,
            'default_value' => '',
            'toolbar' => 'full',
            'media_upload' => 'yes',
        ),
        array (
            'key' => 'field_587957f00aed0',
            'label' => 'Lunch',
            'name' => 'lunch',
            'type' => 'wysiwyg',
            'required' => 1,
            'default_value' => '',
            'toolbar' => 'full',
            'media_upload' => 'yes',
        ),
        array (
            'key' => 'field_587958310aed1',
            'label' => 'Dinner',
            'name' => 'dinner',
            'type' => 'wysiwyg',
            'required' => 1,
            'default_value' => '',
            'toolbar' => 'full',
            'media_upload' => 'yes',
        ),
        array (
            'key' => 'field_58795c760f586',
            'label' => 'Direction',
            'name' => '',
            'type' => 'tab',
        ),
        array (
            'key' => 'field_58795c900f587',
            'label' => 'Address',
            'name' => 'address',
            'type' => 'text',
            'default_value' => '',
            'placeholder' => 'Enter Address Here',
            'prepend' => '',
            'append' => '',
            'formatting' => 'none',
            'maxlength' => '',
        ),
        array (
            'key' => 'field_58795d8550af4',
            'label' => 'Contact Details',
            'name' => '',
            'type' => 'tab',
        ),
        array (
            'key' => 'field_58795da950af5',
            'label' => 'Email',
            'name' => 'email',
            'type' => 'email',
            'required' => 1,
            'default_value' => '',
            'placeholder' => 'Enter contact Email Address here',
            'prepend' => '',
            'append' => '',
        ),
        array (
            'key' => 'field_58795dde50af6',
            'label' => 'Phone Number',
            'name' => 'phone_number',
            'type' => 'text',
            'required' => 1,
            'default_value' => '',
            'placeholder' => 'Enter Reachable Contact Phone Number Here.',
            'prepend' => '',
            'append' => '',
            'formatting' => 'html',
            'maxlength' => '',
        ),
    ),
    'location' => array (
        array (
            array (
                'param' => 'page',
                'operator' => '==',
                'value' => '15',
                'order_no' => 0,
                'group_no' => 0,
            ),
        ),
    ),
    'options' => array (
        'position' => 'normal',
        'layout' => 'default',
        'hide_on_screen' => array (
        ),
    ),
    'menu_order' => 0,
));
register_field_group(array (
    'id' => 'acf_signature-dishes',
    'title' => 'Signature Dishes',
    'fields' => array (
        array (
            'key' => 'field_5878ff13d8ea4',
            'label' => 'Signature Dishes',
            'name' => 'signature_dishes',
            'type' => 'text',
            'required' => 1,
            'default_value' => '',
            'placeholder' => 'Enter Title Here Please',
            'prepend' => '',
            'append' => '',
            'formatting' => 'none',
            'maxlength' => '',
        ),
    ),
    'location' => array (
        array (
            array (
                'param' => 'page',
                'operator' => '==',
                'value' => '15',
                'order_no' => 0,
                'group_no' => 0,
            ),
        ),
    ),
    'options' => array (
        'position' => 'normal',
        'layout' => 'no_box',
        'hide_on_screen' => array (
        ),
    ),
    'menu_order' => 0,
));

endif;

  • 写回答

1条回答 默认 最新

  • dongtangu8403 2017-01-23 06:35
    关注

    Thanks for posting your code that helped a lot.

    the code is correct, the only possible error is with including the acf.php

    if you have access to the FTP, put "advanced-custom-fields" folder next to the functions.php file. (in the same directory)

    now in functions.php (the code you posted above) find this line:

    include_once('/advanced-custom-fields/acf.php');
    

    replace it with this:

     include_once('advanced-custom-fields/acf.php');
    

    let me know if that doesn't work.

    Thanks

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

报告相同问题?

悬赏问题

  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿