Home Forums Bug Reports ACF Pro – Options pages with Repeaters not working Reply To: ACF Pro – Options pages with Repeaters not working

  • If you know how to parse values from a WordPress database object you can query the options page. I have a repeating field called slides on a options page. It has three subfields slide_image, slide_caption, slide_link. I got the array length by using this code.

    $my_count = $wpdb->get_results($wpdb->prepare("SELECT 'option_value' FROM '$wpdb->options' WHERE 'option_name' = 'options_slides' "));

    In my case this returned:

    [0] => stdClass Object ( [option_value] => 6 )

    next to get the all the subfields I used this query:

    $my_rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM '$wpdb->options' WHERE 'option_name' REGEXP '^(options_slides)' "));

    which returns (partial example)

    [0] => stdClass Object
                [option_id] => 35462
                [option_name] => options_slides_0_slide_image
                [option_value] => 13282
                [autoload] => yes
        [1] => stdClass Object
                [option_id] => 35464
                [option_name] => options_slides_0_slide_caption
                [option_value] => <h2>My Caption Title</h2>
    Discover Portland's best restaurants, bars, cafes and bakeries
                [autoload] => yes
        [2] => stdClass Object
                [option_id] => 35466
                [option_name] => options_slides_0_slide_link
                [option_value] =>
                [autoload] => yes

    options_slides_0_slide_image is from the options page. options_slides_0_slide_image is your repeating field name. options_slides_0_slide_image is the number of the element in the array. options_slides_0_slide_image is the name of the subfield in the repeater. Since I have 6 repeating fields the last image slide is options_slides_5_slide_image. This is my be very geeky, but maybe it will help. These comments are only related to version 5.x. For MySQL queries us a prime character ` not a single quote .