Grow your CSS skills. Land your dream job.

Advanced Custom Fields displaying ‘Array’ instead of showing image

  • # December 16, 2012 at 9:26 am

    Hi Guys

    I am using the Advanced Custom Fields plugin with the Repeater Field add-on to display a product image, description and price.

    This works fine on most fields, however, when the field type is an image, it just displays the word ‘array’ on the website.

    Here is my code to call the plugin….

    < ?php

    $rows = get_field(‘products’);
    if($rows) {

    foreach($rows as $row)
    {
    echo $row, $row, $row;
    }
    }

    ?>

    and here is what it outputs… http://noteha.co.uk/dev/products/ – The word ‘Array’ is where the image should go.

    These are my admin settings http://dl.dropbox.com/u/94593656/Screen%20Shot%202012-12-16%20at%2014.24.05.png and the image does display on the page admin.

    I can’t think what this could be.

    Any help would be great.

    # December 16, 2012 at 9:41 am

    Ok figured it out, I had to actually state the img src in my code.

    For any one else that wants to know, the correct code should be this..

    < ?php

    $rows = get_field(‘products’);
    if($rows) {

    foreach($rows as $row)
    {
    echo ‘‘, $row, $row;
    }
    }

    ?>

    # December 16, 2012 at 10:32 am

    I was about to say you have to wrap it in `` but you already figured it out.

    I had the same problem the other week and couldn’t figure it out.

    # December 16, 2012 at 1:51 pm

    yeh it’s a shame they don’t include this on the documentation (unless I missed it) but it truly is a great plug-in and add-on.

    # December 16, 2012 at 9:40 pm

    @croydon86

    > yeh it’s a shame they don’t include this on the documentation (unless I missed it) but it truly is a great plug-in and add-on.

    This is a standard method of using images within WordPress, pre-wrapping an image with an HTML `` can cause issues because there are instances where we may only want the URL to the image and nothing else.

    While it may not be specified in the plugin docs I have seen somewhere in the WordPress docs that it does only return paths.

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

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".