title: Including ACF in functions.php (WordPress)
body: <p>I'm making a theme to sell on theme forrest for the first time. I've used ACF as a standard plugin during development to make sure everything's working.</p>
  
  <p>I've almost finished so decided to export my <code>ACF</code> to <code>PHP</code> and include it into my <code>functions.php</code> file.</p>
  
  <p>I copy/pasted the code it gave me into <code>functions.php</code> and included <code>ACF</code>, <code>options-page</code>, and <code>repeater-field</code> into a folder within my theme and referenced them accordingly.</p>
  
  <p>However, when I visit my site I get this error:</p>
  
  <p><code>Fatal error: Cannot redeclare class Acf in /Applications/MAMP/htdocs/omg/wp-content/themes/omg-v1/external/acf/acf.php on line 46</code></p>
  
  <p>I've removed the actual plugin files from the plugins folder also.</p>
  
  <p>Any ideas why it might be bugging out? </p>
  
  <p>I know it's a lot of code, but incase anyone wants to look this is the code that's in my <code>functions.php</code> (which ACF gave me)</p>
  
  <pre><code>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' =&gt; 'acf_featured-story',
          'title' =&gt; 'Featured Story',
          'fields' =&gt; array (
              array (
                  'key' =&gt; 'field_5256bd0fc7592',
                  'label' =&gt; 'Is this story featured?',
                  'name' =&gt; 'featured-story',
                  'type' =&gt; 'true_false',
                  'message' =&gt; 'Yes',
                  'default_value' =&gt; 0,
              ),
          ),
          'location' =&gt; array (
              array (
                  array (
                      'param' =&gt; 'post_type',
                      'operator' =&gt; '==',
                      'value' =&gt; 'post',
                      'order_no' =&gt; 0,
                      'group_no' =&gt; 0,
                  ),
              ),
          ),
          'options' =&gt; array (
              'position' =&gt; 'side',
              'layout' =&gt; 'default',
              'hide_on_screen' =&gt; array (
              ),
          ),
          'menu_order' =&gt; 0,
      ));
      register_field_group(array (
          'id' =&gt; 'acf_options',
          'title' =&gt; 'Options',
          'fields' =&gt; array (
              array (
                  'key' =&gt; 'field_525d1b6d49043',
                  'label' =&gt; 'Homepage Layout (Left Column)',
                  'name' =&gt; 'homepage-layout-left',
                  'type' =&gt; 'repeater',
                  'instructions' =&gt; 'Select which categories you want to display on the homepage.',
                  'sub_fields' =&gt; array (
                      array (
                          'key' =&gt; 'field_525d1b8a49044',
                          'label' =&gt; 'Category',
                          'name' =&gt; 'category',
                          'type' =&gt; 'taxonomy',
                          'column_width' =&gt; '',
                          'taxonomy' =&gt; 'category',
                          'field_type' =&gt; 'select',
                          'allow_null' =&gt; 0,
                          'load_save_terms' =&gt; 0,
                          'return_format' =&gt; 'id',
                          'multiple' =&gt; 0,
                      ),
                      array (
                          'key' =&gt; 'field_525d2473de72c',
                          'label' =&gt; 'Number of Posts',
                          'name' =&gt; 'number-of-posts',
                          'type' =&gt; 'number',
                          'column_width' =&gt; '',
                          'default_value' =&gt; 4,
                          'placeholder' =&gt; '',
                          'prepend' =&gt; '',
                          'append' =&gt; '',
                          'min' =&gt; 2,
                          'max' =&gt; '',
                          'step' =&gt; 2,
                      ),
                  ),
                  'row_min' =&gt; 1,
                  'row_limit' =&gt; 4,
                  'layout' =&gt; 'row',
                  'button_label' =&gt; 'Add a category',
              ),
              array (
                  'key' =&gt; 'field_525d25ee91b41',
                  'label' =&gt; 'Homepage Layout (Sidebar)',
                  'name' =&gt; 'homepage-layout-sidebar',
                  'type' =&gt; 'repeater',
                  'instructions' =&gt; 'Select which categories you want to display in the sidebar.',
                  'sub_fields' =&gt; array (
                      array (
                          'key' =&gt; 'field_525d25ee91b42',
                          'label' =&gt; 'Category',
                          'name' =&gt; 'category',
                          'type' =&gt; 'taxonomy',
                          'column_width' =&gt; '',
                          'taxonomy' =&gt; 'category',
                          'field_type' =&gt; 'select',
                          'allow_null' =&gt; 0,
                          'load_save_terms' =&gt; 0,
                          'return_format' =&gt; 'id',
                          'multiple' =&gt; 0,
                      ),
                      array (
                          'key' =&gt; 'field_525d25ee91b43',
                          'label' =&gt; 'Number of Posts',
                          'name' =&gt; 'number-of-posts',
                          'type' =&gt; 'number',
                          'column_width' =&gt; '',
                          'default_value' =&gt; 4,
                          'placeholder' =&gt; '',
                          'prepend' =&gt; '',
                          'append' =&gt; '',
                          'min' =&gt; 2,
                          'max' =&gt; '',
                          'step' =&gt; 2,
                      ),
                  ),
                  'row_min' =&gt; 1,
                  'row_limit' =&gt; 4,
                  'layout' =&gt; 'row',
                  'button_label' =&gt; 'Add a category',
              ),
              array (
                  'key' =&gt; 'field_525d2afdf101b',
                  'label' =&gt; 'Newsletter (optional)',
                  'name' =&gt; 'newsletter',
                  'type' =&gt; 'repeater',
                  'sub_fields' =&gt; array (
                      array (
                          'key' =&gt; 'field_525d2b6612426',
                          'label' =&gt; 'Link',
                          'name' =&gt; 'link',
                          'type' =&gt; 'text',
                          'instructions' =&gt; 'If you have a newsletter, copy/paste your link in here.',
                          'column_width' =&gt; '',
                          'default_value' =&gt; '',
                          'placeholder' =&gt; '',
                          'prepend' =&gt; '',
                          'append' =&gt; '',
                          'formatting' =&gt; 'none',
                          'maxlength' =&gt; '',
                      ),
                      array (
                          'key' =&gt; 'field_525d2bb40e332',
                          'label' =&gt; 'Text',
                          'name' =&gt; 'text',
                          'type' =&gt; 'textarea',
                          'instructions' =&gt; 'Enter your call to action for the newsletter here.',
                          'column_width' =&gt; '',
                          'default_value' =&gt; 'Subscribe!
  
                          To the OMG! newsletter!',
                          'placeholder' =&gt; '',
                          'maxlength' =&gt; 100,
                          'formatting' =&gt; 'br',
                      ),
                  ),
                  'row_min' =&gt; 0,
                  'row_limit' =&gt; 1,
                  'layout' =&gt; 'row',
                  'button_label' =&gt; 'Add Newsletter Link',
              ),
              array (
                  'key' =&gt; 'field_525e8b77edf6e',
                  'label' =&gt; 'Advert',
                  'name' =&gt; 'adverts',
                  'type' =&gt; 'repeater',
                  'instructions' =&gt; 'Do you wish to display an advert in your sidebar?',
                  'sub_fields' =&gt; array (
                      array (
                          'key' =&gt; 'field_525e8c1e3600f',
                          'label' =&gt; 'Advert Image',
                          'name' =&gt; 'advert-img',
                          'type' =&gt; 'image',
                          'instructions' =&gt; 'Upload a 300 x 200px image for best quality / load time',
                          'column_width' =&gt; '',
                          'save_format' =&gt; 'url',
                          'preview_size' =&gt; 'full',
                          'library' =&gt; 'all',
                      ),
                      array (
                          'key' =&gt; 'field_525e8d1699619',
                          'label' =&gt; 'Link',
                          'name' =&gt; 'ad-link',
                          'type' =&gt; 'text',
                          'column_width' =&gt; '',
                          'default_value' =&gt; '',
                          'placeholder' =&gt; '',
                          'prepend' =&gt; '',
                          'append' =&gt; '',
                          'formatting' =&gt; 'none',
                          'maxlength' =&gt; '',
                      ),
                  ),
                  'row_min' =&gt; 0,
                  'row_limit' =&gt; 1,
                  'layout' =&gt; 'table',
                  'button_label' =&gt; 'Add an Advert',
              ),
          ),
          'location' =&gt; array (
              array (
                  array (
                      'param' =&gt; 'options_page',
                      'operator' =&gt; '==',
                      'value' =&gt; 'acf-options',
                      'order_no' =&gt; 0,
                      'group_no' =&gt; 0,
                  ),
              ),
          ),
          'options' =&gt; array (
              'position' =&gt; 'normal',
              'layout' =&gt; 'no_box',
              'hide_on_screen' =&gt; array (
              ),
          ),
          'menu_order' =&gt; 0,
      ));
  }
  </code></pre>