Installing ACF With Composer

Last updated Oct 31, 2024

Overview

Both ACF and ACF PRO can be installed using Composer.

These instructions cover how to install the free version of ACF with Composer. Please view Installing ACF PRO with Composer for details of how to use ACF PRO with Composer.

Add Our Repository

Add our repository to your composer.json file:


"repositories": [
    {
        "type":"composer",
        "url":"https://composer.advancedcustomfields.com"
    }
]

Install the Plugin

From the CLI, require ACF using the following command:


composer require wpengine/advanced-custom-fields

Version Constraints

You can use any Composer version constraints, or specify the exact version of the plugin:


"require": {
    "wpengine/advanced-custom-fields": "6.3.9"
}

Customizing Install Locations

We use composer/installers to automatically install our plugin package to wp-content/plugins/. However, you can customize the install location by adding the following to your composer.json file:


"extra": {
    "installer-paths": {
        "wp-content/plugins/{$name}/": ["type:wordpress-plugin"]
    }
}

Installing as an MU Plugin

If you prefer to install ACF as a must use plugin (mu-plugin), to ensure it will always be loaded by WordPress and can’t be deactivated from the admin dashboard like a normal plugin, you can alter the install location by adding the following to your composer.json file:


"extra": {
    "installer-paths": {
        "wp-content/mu-plugins/{$name}/": ["wpengine/advanced-custom-fields"]
    }
}

However, plugin directories inside the mu-plugin directory will not be loaded automatically by WordPress, so you would need to require it manually with an acf.php file in the mu-plugin directory root:


<?php
require_once WPMU_PLUGIN_DIR . '/advanced-custom-fields/acf.php';

As an alternative, there is a package that automatically handles loading directories in the mu-plugin directory.

Example composer.json


{
    "name": "wpengine/composer-test.dev",
    "description": "ACF in a WordPress site",
    "repositories": [
        {
            "type":"composer",
            "url":"https://composer.advancedcustomfields.com"
        }
    ],
    "require": {
        "wpengine/advanced-custom-fields": "^6",
    }
}
Supercharge Your Website With Premium Features Using ACF PRO

Speed up your workflow and unlock features to better develop websites using ACF Blocks and Options Pages, with the Flexible Content, Repeater, Clone, Gallery Fields & More.

Explore Features View Pricing

PRO Features
ACF Blocks
Options Pages
PRO Fields
Repeater
Flexible Content
Gallery
Clone