Support

Account

Home Forums Add-ons Options Page Options Page + Repeater Field, Seems simple?

Solved

Options Page + Repeater Field, Seems simple?

  • Hello!

    Having issues with querying the repeater field within my options. I can query a simple option field and I can query a repeater but I can’t seem to do both.

    I assume ‘option’ is the post id?

    <?php the_field('field_name’, 'option'); ?>

    So … why doesn’t this work?

    	<?php while(has_sub_field('company_profile_hours_general', 'option')): ?>
    		<?php the_sub_field('company_profile_hours_general_day'); ?>
    		<?php the_sub_field('company_profile_hours_general_time_open'); ?>
    		<?php the_sub_field('company_profile_hours_general_time_close'); ?>
    	<?php endwhile; ?>
  • Hi @Jayson

    Yes, this should work as expected. Can you confirm you are using the correct field names?

    Also, where in your theme are you running this code? In what file?
    Also, try debugging the data like so:

    
    <?php 
    
    echo '<pre>';
    	print_r( get_field('company_profile_hours_general', 'option') );
    echo '</pre>';
    die; 
    
    ?>
    
  • Hi Elliot,

    I know what’s happening … the values are not saving… even with a new field.

  • Hi @Jayson

    Just to clarify, when you edit a custom field on the options page, the value does not save, and when the edit screen reloads, the new value does not appear?

  • Hi elliot,

    Correct. The repeater / options work fine on there own. I haven’t had the time to setup a unique test bench to re-produce this error.

    Sorry for the delayed response, self employed worker bee.

  • Hi @Jayson

    Is it possible that the field names are too long to be saved in to the WP table?

    Can you list the full field name + child field names for the longest possible combination?

    eg:
    repeater = company_profile_hours_general
    sub field = image_that_has_a_long_name

  • Hi Elliot,

    Thanks for seeing this through. We just had a Holiday in Canada, I have been away from my office (bedroom).

    I believe you are correct; the meta names were too long. I reduced them and they save correctly!

    Cheers,

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

The topic ‘Options Page + Repeater Field, Seems simple?’ is closed to new replies.