Support

Account

Home Forums ACF PRO ACF in premium theme: add tables when installing theme Reply To: ACF in premium theme: add tables when installing theme

  • This is kinda off the top of my head. So there may be a better solution, as this is untested and might not even work. LOL 😛

    The first thing you need is to ensure that the plugin is included and activated upon install…

    So I would add the plugin to the theme via functions.php:

    // set the path to the includes folder
    define('THEME_INCLUDES', TEMPLATEPATH . '/inc/');
    
    // load the ACF plugin
    require_once (THEME_INCLUDES . 'advanced-custom-fields-pro/acf.php');
    
    // hide the custom fields menu from the dashboard
    define( 'ACF_LITE', true );

    then include ACF within your theme structure:

    your-theme/
    -inc/
    –advanced-custom-fields-pro/
    —acf.php
    -functions.php
    -header.php
    -style.css

    and so on

    Then in your dev theme, after you’ve created all the custom fields goto Custom Fields > Import/Export choose all the fields you want to export, then click “generate export code” copy that code and paste it into your themes functions.php file.

    This assumes you just want to add the existing fields and not any content you have added to them.

    You will also probably want to make heavy use of:

    <?php 
     if ( !empty('field') ) { 
      // do this 
     } else {
      // do that
     }
    ?>

    Hope this helps in some way. 🙂