Home Forums Add-ons Repeater Field Repeater field it shows the taxonomy ID instead of the value text


Repeater field it shows the taxonomy ID instead of the value text

  • Hello, I’m using a script I found to add repeaters fields using shortcodes. The script works fine for almost everything, but when I want to use a taxonomy subfield I get only the number ID. What I need to add or modify in this code to make this repeater shows the text value?

     * ACF Pro repeater field shortcode
     * I created this shortcode function because it didn't exist and it was being requested by others
     * I originally posted it here:
     * @attr {string} field - (Required) the name of the field that contains a repeater sub group
     * @attr {string} sub_fields - (Required) a comma separated list of sub field names that are part of the field repeater group
     * @attr {string} post_id - (Optional) Specific post ID where your value was entered. Defaults to current post ID (not required). This can also be options / taxonomies / users / etc
    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");

    Code to show the shortcodes:

    [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.