title: How to programmatically add an ACF group to the backend of Wordpress?
body: <p>I've tried a bunch of different functions and approaches but so far I haven't been able to get it working.
  The goal is to add an Advanced Custom Field group to the backend of Wordpress with some PHP-code. In the best scenario we add the PHP-code to a method of a class.</p>
  
  <pre><code>public function create_group( $group_name ) {
  
      if ( $this-&gt;does_group_already_exists( $group_name ) ) {
          return false;
      }
  
      acf_add_local_field_group( array(
          'key'      =&gt; 'group_1',
          'title'    =&gt; 'My Group',
          'fields'   =&gt; array(
              array(
                  'key'   =&gt; 'field_1',
                  'label' =&gt; 'Sub Title',
                  'name'  =&gt; 'sub_title',
                  'type'  =&gt; 'text',
              )
          ),
          'location' =&gt; array(
              array(
                  array(
                      'param'    =&gt; 'post_type',
                      'operator' =&gt; '==',
                      'value'    =&gt; 'post',
                  ),
              ),
          ),
      ) );
  
      return true;
  }
  </code></pre>
  
  <p>Nothing gets added with the code above. I also tried adding it to <code>functions.php</code> and it with a <code>add_action()</code> function like so:</p>
  
  <pre><code>add_action( 'acf/init', array( $this, 'create_group' ) );
  </code></pre>
  
  <p>But again, no results. </p>
  
  <p>Hope some one can share a working solution.</p>