• Resolved Dennis Dallau

    (@yorlinqnl)


    I have created an option page with a few options nicely stored in the database.

    I have to echo the array of

    get_option('bookings_bookings_settings_opening_days')

    but I can’t get it to work. A simple foreach doesn’t seem to work…

    The value stored in the database looks like this:

    a:6:{i:0;s:2:"Ma";i:1;s:2:"Di";i:2;s:2:"Wo";i:3;s:2:"Do";i:4;s:2:"Vr";i:5;s:2:"Za";}

    And I need the output look like this: Ma Di Wo Do Vr Za

    Just to be complete… this does not work:

    $exeptions = get_option('bookings_bookings_settings_opening_days');
    foreach ($exeptions as $exeption) {
        echo $exeption;
    }
    • This topic was modified 4 years, 9 months ago by Dennis Dallau.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    This issue doesn’t seems related to ACF Extended and is more a general WP/PHP dev question. I’ll try to help you, especially after the nice review you left yesterday.

    But you need to understand that I’m already really busy with work on ACF Extended, so I can’t help everyone that have problems with general WP/PHP development.

    I tested your code, and it works. You need to check that your option is correctly set in Settings > Options menu (you can search for the term: bookings), or directly in PHPMyAdmin.

    If you use an ACF Options Page, then bookings is most likely your Options Page Post ID (as your option name starts with bookings_). So bookings_settings_opening_days is most likely your ACF Field in that options page.

    You should stick to ACF functions if you work with ACF modules. In order to retrive you option page fields, you should use the following code: get_field('bookings_settings_opening_days', 'bookings') instead of get_option().

    Here are some resources on ACF Options Page:
    https://www.advancedcustomfields.com/add-ons/options-page/
    https://www.advancedcustomfields.com/resources/get-values-from-an-options-page/

    If you’re not really comfortable with Option Page custom Post ID, you should stick to the default Post ID, which is options. You option name will be: options_bookings_settings_opening_days, and you’ll have to retrieve the data using get_field('bookings_settings_opening_days', 'options');.

    Regards.

    Thread Starter Dennis Dallau

    (@yorlinqnl)

    tnx. solved

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Awesome!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Output array of option field’ is closed to new replies.