Support

Account

Home Forums Add-ons Repeater Field Having issues with ACF Repeater fields on a multisite Reply To: Having issues with ACF Repeater fields on a multisite

  • It’s not specifically for generatepress; this is the code:

    
    function my_acf_repeater($atts, $content='') {
      extract(shortcode_atts(array(
        "field" => null,
        "sub_fields" => null,
        "post_id" => null
      ), $atts));
      if (empty($field) || empty($sub_fields)) {
        // silently fail? is that the best option? idk
        return "";
      }
      $sub_fields = explode(",", $sub_fields);
      $_finalContent = '';
      if( have_rows($field, option) ):
        while ( have_rows($field, option) ) : the_row();
          $_tmp = $content;
          foreach ($sub_fields as $sub) {
            $subValue = get_sub_field(trim($sub));
            $_tmp = str_replace("%$sub%", $subValue, $_tmp);
          }
          $_finalContent .= do_shortcode( $_tmp );
        endwhile;
      else :  
        $_finalContent = "<center><h2>There is nothing to see here right now!</h2><br><p>Please check back soon</p></center>";
      endif;
      return $_finalContent;
    }
    add_shortcode("acf_repeater", "my_acf_repeater");