Support

Account

Home Forums General Issues Include ACF pro in theme

Helping

Include ACF pro in theme

  • Hello,

    we want to create a blank starter theme for our projects where all
    needed plugins are included. We’re using TGM plugin activation class – how
    can ACf functions like creating the option page an creating the needed fields be
    run in functions.php so that they are called AFTER ACF installation & activation?

    Best
    P.

  • You add filters and actions.

    I’m pretty sure this is all in the documentation somewhere so this is just a quick overview.

    Examples:

    
    // add options pages
    add_action('init', 'add_theme_options_pages');
    function add_theme_options_pages() {
        if (!function_exists('acf_add_options_sub_page')) {
            return;
        }
        // add code here to add options pages
    }
    
    
    // add custom fields
    // export the field groups and use below
    add_action('acf/include_fields', 'add_theme_field_groups');
    function add_theme_field_groups() {
        // you can get the code you need here by exporting
        // your field group to PHP
        // you could also use JSON, search for ACF Local JSON
    }
    

    Hope this helps.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Include ACF pro in theme’ is closed to new replies.