Home Forums Add-ons Repeater Field Calling in Custom Fields


Calling in Custom Fields

    • Damsel

    • October 29, 2013 at 6:11 pm

    I’m pretty new to this and need some basic help.

    I have created a template for my page ‘stockists’, attached that to a page in wordpress (also stockists) and used advanced custom fields & repeater fields to add my content. When I visit the page in question in the back end of wordpress I can see my custom fields and edit them just fine.

    When I ‘view page’ however, I see nothing. I’ve added the following code to the page-template.php:

    <?php the_field ('stockists'); ?>

    What am I doing wrong?
    Thanks in advance to anyone who can help a newbie! 🙂

  • Have you put the code inside of the loop? The loop is the while loop looking something like:

    <?php while(have_posts()): the_post(); ?>
    • Damsel

    • November 3, 2013 at 1:19 pm

    Like this?

    <?php while(have_posts()): the_post(); ?>
            <p><?php the_field('stockists'); ?></p>
            <?php endwhile; ?>

    My page displays the header and footer (just under the header) and it says ‘array, array’ where the page and it’s custom fields should be.

    • Elliot

    • November 4, 2013 at 4:17 pm

    Hi @Damsel

    What kind of field is ‘stockists’?

    From what you have posted, it looks liek the returned value is a bunch of array’s

    Perhaps you need to read over the docs and see how to use the functions to render out the HTML into your template.


    • Damsel

    • November 4, 2013 at 4:25 pm

    Thanks to both for your help. I was using the_repeater_field and only calling in the_field! Love that moment when the penny drops!

    • Elliot

    • November 4, 2013 at 4:49 pm

    Hi @Damsel

    Glad you found a solution but perhaps you could provide a clearer explanation of the solution for other readers?


    • Damsel

    • November 4, 2013 at 4:57 pm

    Sure. I purchased the add-on for “repeater” fields, to make it easier to add several lines of information.

    The initial code above just calls in the field ‘stockists’ (the name of the ACF I created). What I needed to do was call in the ‘repeater_field’ followed by each repeated field. Here’s the correct code..

    <?php while(the_repeater_field('stockists')): ?>
    <div class="stockists"><br />
    	<strong><?php the_sub_field('stockists_name'); ?></strong><br />
    	<?php the_sub_field('address'); ?><br />
    	<?php the_sub_field('address_2'); ?><br />
    	<?php the_sub_field('city'); ?><br />
    	<strong><?php the_sub_field('phone_number'); ?></strong><br />
    	<?php the_sub_field('website'); ?><br />

    So ‘stockists’ was the original custom field. Name, address, city etc are the repeater fields.

Viewing 7 posts - 1 through 7 (of 7 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.