Home Forums General Issues Repeater field data not showing on site


Repeater field data not showing on site

  • Hi, I have seen this issue on other threads. But none of them helped me. I will try my luck again with this.

    For one of my posts I have quite a few different repeaters for different kinds of pricing. All the data gets saved to the database. It shows up in the admin for that page. But nothing can be seen on the site itself.

    From the start I have had this working. For some reason it just stopped working like a week ago.

    I have tried disabeling all the other plugins.

    Any ideas? What more do you need frpm me to be able to investigate?

  • Hi @rammelasen

    What code are you using to render out the data? Can you provide snippets of the troublesome code.

    Can you also debug the code line by line to find out what does and deosn’t work.


  • This reply has been marked as private.
  • Hello again. A guy at my hosting company tried around a bit and came to the conclusion that if you put the post ID in the has_sub_filed();/the_sub_field(); the data shows. Like it doesn’t know where it is assigned to?

    Like this (the “73”):

    <?php while(has_sub_field("segment_servicepriser", 73)): ?>										<h3><?php the_sub_field('segmentrubrik', 73); ?></h3>					<ul class="artikel bigbox list">
    <?php while(has_sub_field('artikel', 73)): ?>
    																<li class="con60">															<?php if(get_sub_field('namn', 73)){															echo the_sub_field('namn', 73);												} else {													echo '-||-';															}?>															</li>																<li class="con20 right"><?php the_sub_field('pris'); ?>:-</li>															<li class="con20 info right"><?php the_sub_field('info'); ?></li>													</ul>

    And so on… The 73 is the current ID of one of the pages spitting this date out. So if I want the same data to spit out somwhere else I have to put that ID in too.

    I can’t recall that this was an issue before?

    What do you think?

    thanks again

    regards / Jeppe

  • Hi @rammelasen

    The $post_id parameter you are talking about tis an option to target a post to load data from.

    FYI: the the_sub_field function does NOT contain a $post_id parameter. This is incorrect

    If adding this 73 as the $post_id to the has_sub_field function, then this confirms that ACF is not able to find the correct $post_id on its own.

    Perhaps the issue is caused by another plugin or code (which contains a WP_Query loop / setup_postdata function) that is modifying the global $post object.

    Before your ACF code, can you dump out the global post id like so:

    global $post;
    echo '<pre>';
    echo '</pre>';

    What value to you get? Is this the correct ID for the page?


  • Hi @elliot, it says:

    “int 38”

    Dunno what to do with that?

    Cheers / Jeppe

  • Omg! I’m such a douche. I totally forgot to put in the standard loop.

    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <?php endwhile; ?>

    I wrapped the whole page in it and everything works again. I’m so sorry for this 🙂 I can’t believe I didn’t see that and wasted your time.

    Regards / Jeppe

  • Also I forgot to mention that it was a page, not a post, outputing the data. But should that really matter? Can you treat a page like a post and retrieve data from one page and output it in another?


  • So basically what I do now is wrap the code into this instead:

    <?php $pistkarta = new WP_Query( array( 'page_id' => 73, 'showposts' => -1 ));
    							while ( $pistkarta->have_posts() ) : $pistkarta->the_post(); ?>
    /* Content here from page with ID 73 */
    <?php endwhile; ?> 


  • Hi @rammelasen

    I’m not sure if the page_id argument will ignore the post_type argument (defaults to ‘post’).

    Perhaps this is documented in the WP WP_Query args documentation.


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

The topic ‘Repeater field data not showing on site’ is closed to new replies.