테마 포레스트에서 처음으로 판매 할 테마를 만들고 있습니다. ACF를 모든 플러그인이 작동하는지 확인하는 표준 플러그인으로 사용했습니다.functions.php (WordPress)에 ACF 포함
거의 완료되었으므로 ACF
을 PHP
으로 내 보내서 내 functions.php
파일에 포함 시켰습니다.
나는 복사 /이 functions.php
에 준 나의 테마 내 폴더에 ACF
, options-page
및 repeater-field
을 포함하고 적절하게 참조하는 코드를 붙여 넣습니다. 나는 또한 플러그인 폴더에서 실제 플러그인 파일을 삭제 한
Fatal error: Cannot redeclare class Acf in /Applications/MAMP/htdocs/omg/wp-content/themes/omg-v1/external/acf/acf.php on line 46
: 나는 내 사이트를 방문 할 때
그러나,이 오류가 발생합니다.
왜 도청의 원인이 될만한 아이디어가 있습니까?
나는 그것이 코드를 많이 알고 있지만 넣다 사람이를보고 싶어은에서의 코드 내 functions.php
(ACF 내게 준) 당신은 당신이 충돌하지 않습니다 포함되어 있는지 확인해야합니다
include_once('external/acf/acf.php');
define('ACF_LITE' , true);
// Add-ons
include_once('external/acf-repeater/acf-repeater.php');
include_once('external/acf-options-page/acf-options-page.php');
if(function_exists("register_field_group"))
{
register_field_group(array (
'id' => 'acf_featured-story',
'title' => 'Featured Story',
'fields' => array (
array (
'key' => 'field_5256bd0fc7592',
'label' => 'Is this story featured?',
'name' => 'featured-story',
'type' => 'true_false',
'message' => 'Yes',
'default_value' => 0,
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'post',
'order_no' => 0,
'group_no' => 0,
),
),
),
'options' => array (
'position' => 'side',
'layout' => 'default',
'hide_on_screen' => array (
),
),
'menu_order' => 0,
));
register_field_group(array (
'id' => 'acf_options',
'title' => 'Options',
'fields' => array (
array (
'key' => 'field_525d1b6d49043',
'label' => 'Homepage Layout (Left Column)',
'name' => 'homepage-layout-left',
'type' => 'repeater',
'instructions' => 'Select which categories you want to display on the homepage.',
'sub_fields' => array (
array (
'key' => 'field_525d1b8a49044',
'label' => 'Category',
'name' => 'category',
'type' => 'taxonomy',
'column_width' => '',
'taxonomy' => 'category',
'field_type' => 'select',
'allow_null' => 0,
'load_save_terms' => 0,
'return_format' => 'id',
'multiple' => 0,
),
array (
'key' => 'field_525d2473de72c',
'label' => 'Number of Posts',
'name' => 'number-of-posts',
'type' => 'number',
'column_width' => '',
'default_value' => 4,
'placeholder' => '',
'prepend' => '',
'append' => '',
'min' => 2,
'max' => '',
'step' => 2,
),
),
'row_min' => 1,
'row_limit' => 4,
'layout' => 'row',
'button_label' => 'Add a category',
),
array (
'key' => 'field_525d25ee91b41',
'label' => 'Homepage Layout (Sidebar)',
'name' => 'homepage-layout-sidebar',
'type' => 'repeater',
'instructions' => 'Select which categories you want to display in the sidebar.',
'sub_fields' => array (
array (
'key' => 'field_525d25ee91b42',
'label' => 'Category',
'name' => 'category',
'type' => 'taxonomy',
'column_width' => '',
'taxonomy' => 'category',
'field_type' => 'select',
'allow_null' => 0,
'load_save_terms' => 0,
'return_format' => 'id',
'multiple' => 0,
),
array (
'key' => 'field_525d25ee91b43',
'label' => 'Number of Posts',
'name' => 'number-of-posts',
'type' => 'number',
'column_width' => '',
'default_value' => 4,
'placeholder' => '',
'prepend' => '',
'append' => '',
'min' => 2,
'max' => '',
'step' => 2,
),
),
'row_min' => 1,
'row_limit' => 4,
'layout' => 'row',
'button_label' => 'Add a category',
),
array (
'key' => 'field_525d2afdf101b',
'label' => 'Newsletter (optional)',
'name' => 'newsletter',
'type' => 'repeater',
'sub_fields' => array (
array (
'key' => 'field_525d2b6612426',
'label' => 'Link',
'name' => 'link',
'type' => 'text',
'instructions' => 'If you have a newsletter, copy/paste your link in here.',
'column_width' => '',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'none',
'maxlength' => '',
),
array (
'key' => 'field_525d2bb40e332',
'label' => 'Text',
'name' => 'text',
'type' => 'textarea',
'instructions' => 'Enter your call to action for the newsletter here.',
'column_width' => '',
'default_value' => 'Subscribe!
To the OMG! newsletter!',
'placeholder' => '',
'maxlength' => 100,
'formatting' => 'br',
),
),
'row_min' => 0,
'row_limit' => 1,
'layout' => 'row',
'button_label' => 'Add Newsletter Link',
),
array (
'key' => 'field_525e8b77edf6e',
'label' => 'Advert',
'name' => 'adverts',
'type' => 'repeater',
'instructions' => 'Do you wish to display an advert in your sidebar?',
'sub_fields' => array (
array (
'key' => 'field_525e8c1e3600f',
'label' => 'Advert Image',
'name' => 'advert-img',
'type' => 'image',
'instructions' => 'Upload a 300 x 200px image for best quality/load time',
'column_width' => '',
'save_format' => 'url',
'preview_size' => 'full',
'library' => 'all',
),
array (
'key' => 'field_525e8d1699619',
'label' => 'Link',
'name' => 'ad-link',
'type' => 'text',
'column_width' => '',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'none',
'maxlength' => '',
),
),
'row_min' => 0,
'row_limit' => 1,
'layout' => 'table',
'button_label' => 'Add an Advert',
),
),
'location' => array (
array (
array (
'param' => 'options_page',
'operator' => '==',
'value' => 'acf-options',
'order_no' => 0,
'group_no' => 0,
),
),
),
'options' => array (
'position' => 'normal',
'layout' => 'no_box',
'hide_on_screen' => array (
),
),
'menu_order' => 0,
));
}