Home › Forums › Bug Reports › Slugbug? › Reply To: Slugbug?
Hello Elliot,
sure enough those conditions can all be true.
If the post is of post type course AND it's a child AND it's a child of the post with a value stored in $this->options['webinar_parent']. Come to think of it, I can remove the second statement, but it still works.
The fields all do show up on the right places, that all works nicely. I do always make the fields in the UI and then export it to PHP. Works like a charm.
The value from the field is also stored in the DB. No problems there.
The example above about the webinar code was a poor one, since that one does not show up on an options page.
if(function_exists("register_field_group")) {
register_field_group(array (
'id' => 'acf_webinar-settings',
'title' => __( 'Webinar settings', 'ictrecht' ),
'fields' => array (
array (
'key' => 'field_5266959515e47',
'label' => __( 'Parent', 'ictrecht' ),
'name' => 'webinar_parent',
'type' => 'select',
'choices' => array (
),
'default_value' => '',
'allow_null' => 1,
'multiple' => 0,
),
array (
'key' => 'field_5266967c15e4a',
'label' => __( 'Price', 'ictrecht' ),
'name' => 'webinar_price',
'type' => 'text',
'default_value' => '',
'placeholder' => '',
'prepend' => '€',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
),
array (
'key' => 'field_5266973215e4b',
'label' => __( 'Price for lawyers', 'ictrecht' ),
'name' => 'webinar_lawyer_price',
'type' => 'text',
'default_value' => '',
'placeholder' => '',
'prepend' => '€',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
),
array (
'key' => 'field_5266975c15e4c',
'label' => __( 'Registration form', 'ictrecht' ),
'name' => 'webinar_registration_form',
'type' => 'select',
'choices' => array (
),
'default_value' => '',
'allow_null' => 1,
'multiple' => 0,
),
),
'location' => array (
array (
array (
'param' => 'options_page',
'operator' => '==',
'value' => 'courses_settings',
'order_no' => 0,
'group_no' => 0,
),
),
),
'options' => array (
'position' => 'normal',
'layout' => 'default',
'hide_on_screen' => array (
),
),
'menu_order' => 0,
));
}
This is a good example.
If I now on a single page want to use webinar_price, I try to do this:
echo get_field( 'webinar_price', 'option' );
Or
echo get_field( 'webinar_price', 'options' ); // Should do the same, but tried this one too
But it doesn’t work. If I var dump the return value from get_field I get a false in both cases.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.