Home Forums General Issues Error integrate with plugin


Error integrate with plugin

  • I’m trying to integrate the AFC with a plugin but an error occurs. The fields are all out of place

    it is like this

    so I had to is

    What can be wrong?

    I am using it in my plugin:

    add_filter('acf/settings/path', 'my_acf_settings_path');
    function my_acf_settings_path( $path ) {
        // update path
        $path = plugin_dir_path(__FILE__).'functions/acf/';
        // return
        return $path;
    // 2. customize ACF dir
    add_filter('acf/settings/dir', 'my_acf_settings_dir');
    function my_acf_settings_dir( $dir ) {
        // update path
        $dir = plugins_url(). 'functions/acf/';
        // return
        return $dir;
    // 3. Hide ACF field group menu item
    add_filter('acf/settings/show_admin', '__return_false');
    // 4. Include ACF
    require_once( plugin_dir_path(__FILE__) . 'functions/acf/acf.php' );
    add_filter('acf/settings/load_json', 'my_acf_json_load_point');
    function my_acf_json_load_point( $paths ) {
        // remove original path (optional)
        // append path
        $paths[] = plugin_dir_path(__FILE__).'functions/acf/json';
        // return
        return $paths;
  • Hi @atrevido

    It’s possible that your code is executed before ACF is loaded. Could you please try to add the code in acf/init hook? This page should give you more idea about it:

    Also, please make sure that the returned path and URL are correct. You can also check the developer tools on your browser for any error messages on the page.

    I hope this helps 🙂

  • remove this part and is now functioning normally
    add_filter (‘acf /settings/dir’, ‘my_acf_settings dir’);

  • Hi @atrevido

    Then it means there’s something wrong with how you set the directory. I believe you need to pass __FILE__ constant to get the current directory of the plugin like this:

    $dir = plugins_url( 'functions/acf/', dirname(__FILE__) );

    This page should give you more idea about it:

    I hope this helps 🙂

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

The topic ‘Error integrate with plugin’ is closed to new replies.