Support

Account

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

Solving

Having issues with ACF Repeater fields on a multisite

  • So there is a lot going on with a site I inherited recently at my job. We are using ACF repeater fields to set tables set up with repeated thumbnails, file descriptions and a file download button “broadcasted” with a plugin called ThreeWP Broadcast to all the sites selected from the list of networked multisites. Recently, the repeated thumbnails started returning <img src=”unknown” at the beginning of the repeater code for the inserted thumbnail in the console, and I am not sure what could be causing this. There is a code from John Huebner II placed in the functions.php for GeneratePress, the theme the specific site having these issues is using. Can anyone maybe point me in the direction of some things I should look into? I think it’s notable that I have verified it is calling the correct URL for the images to load when I do the File Editor selection in the Field Group. The permissions for the files are also there, so I am not sure what else could be wrong. We are using ACF Pro and the Options Page addon on WordPress Multisite running 5.4.2. There are User Role Editor plugins installed.

  • I don’t remember ever creating any code for GeneratePress or why it would have my name on it. I’m also not familiar with Broadcast.

  • 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");
    
  • Are you using this shortcode to show this repeater you’re having an issue with? Parts of this code may have come from this forum, but I don’t recall seeing anything like it before and I can tell by looking at the structure used that I didn’t right it.

    There is an error in the code, this

    
    have_rows($field, option)
    

    should be

    
    have_rows($field, 'option')
    

    but I’m not sure that would cause the issue you’re seeing.

  • Gotcha. I am not sure it would cause the issue I am seeing either, but I will change it.

    Is there anyone that is able to login and take a look at this sort of thing? If not, I can try to work based on what you’ve given me so far.

  • I cannot provide that kind of support.

    There is also not enough information.

    If you post the code that is not working I can look at that and see if there’s anything in it that might cause it.

  • This is a users forum, if you need support from the plugin developers you can contact them here https://www.advancedcustomfields.com/contact/

  • This is the code embedded in the page:

    [acf_repeater field="file_listcovid2" sub_fields="thumbnail,description,file_upload,file_type"]
    
     <table style="width:100%">
      <tr>
        <th>Thumbnail</th>
        <th>Description</th>
        <th>Download Link</th>
        <th>File type</th>
      </tr>
      <tr>
        <td><img src="%thumbnail%"/></td>
        <td>%description%</td>
        <td>
    <a href="%file_upload%">Download file</a>
    </td>
     <td>%file_type%</td>
      </tr>
    </table> 
    
    [/acf_repeater]

    It should put out a table that has a thumbnail and a download link like the attached image, but instead it will put out a table that has no working thumbnail repeater field. When you check the source code in the Chrome Inspector while looking at the messed up field, it shows the beginning of the output is “img src= unknown” which tells me it cannot properly get the link to the image for some reason. When I check the console for the working, correct code that is on the dev site currently, it shows this:

    <img src="https://this-is-redacted.com/wp-content/uploads/2020/07/Covid-list-thumb.jpg">

    Another odd thing is that on non-working pages with multiple tables using repeater fields setup via an Options page, all of the fields with thumbnails will say “img src= “unknown” and then the Download File link will share the same PDF- for all the tables on the page. Something programmatic seems to be off, but it’s very hard to track it down.

    I also wanted to throw in- this works on a dev site we made it on, but failed to work upon putting the site in Multisite. We did make sure only the plugins and themes used by the dev were enabled, and verified all other site functionality and other ACF Pro functionality works. All other ACF and Options Page functions on other multisites work.

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

You must be logged in to reply to this topic.