Home Forums Add-ons Repeater Field Repeater shows only the id number of subfield using shortcodes


Repeater shows only the id number of subfield using shortcodes

  • Hello, I’m using this code and is working fine with almost all the fields, but i want to use a taxonomy field and i get only the id value in frontend. How I can modify this code so it shows the taxonomy value and not the id.

    function my_acf_repeater($atts, $content='') {
        "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, $post_id) ):
        while ( have_rows($field, $post_id) ) : 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 );
      else :  
        $_finalContent = "$field does not have any rows";
      return $_finalContent;
    add_shortcode("acf_repeater", "my_acf_repeater");

    this is the code to show in frontend:

    [acf_repeater field="example-row" sub_fields="example-name, example-phone, example-image"]
      User: %example-name%
      Phone: %example-phone%
      profile pic: %example-image%
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.