Home Forums Add-ons Repeater Field Calling in Custom Fields


Calling in Custom Fields

  • Hi,
    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(); ?>
  • 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.

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


  • 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!

  • Hi @Damsel

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


  • 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)

The topic ‘Calling in Custom Fields’ is closed to new replies.