Support

Account

Home Forums Front-end Issues code in function.php doesn't work

Solving

code in function.php doesn't work

  • Hi there,
    I add the following code to the file function.php, but I don’t see the custom field in the front-end of the post, while in the back-end, there are. Why?
    What is there wrong?

    if(function_exists(“register_field_group”))
    {
    register_field_group(array (
    ‘id’ => ‘acf_necrologi’,
    ‘title’ => ‘Necrologi’,
    ‘fields’ => array (
    array (
    ‘key’ => ‘field_52c82fa63aa71’,
    ‘label’ => ‘Nome del defunto’,
    ‘name’ => ‘nome_del_defunto’,
    ‘type’ => ‘text’,
    ‘required’ => 1,
    ‘default_value’ => ”,
    ‘placeholder’ => ”,
    ‘prepend’ => ”,
    ‘append’ => ”,
    ‘formatting’ => ‘html’,
    ‘maxlength’ => ”,
    ),
    array (
    ‘key’ => ‘field_52c82fcb3aa72’,
    ‘label’ => ‘Data del decesso’,
    ‘name’ => ‘data_del_decesso’,
    ‘type’ => ‘date_picker’,
    ‘required’ => 1,
    ‘date_format’ => ‘ddmmyy’,
    ‘display_format’ => ‘dd/mm/yy’,
    ‘first_day’ => 1,
    ),
    array (
    ‘key’ => ‘field_52c82ff73aa73’,
    ‘label’ => ‘Chiesa’,
    ‘name’ => ‘chiesa’,
    ‘type’ => ‘text’,
    ‘required’ => 1,
    ‘default_value’ => ”,
    ‘placeholder’ => ”,
    ‘prepend’ => ”,
    ‘append’ => ”,
    ‘formatting’ => ‘html’,
    ‘maxlength’ => ”,
    ),
    array (
    ‘key’ => ‘field_52c8300e3aa74’,
    ‘label’ => ‘Data del funerale’,
    ‘name’ => ‘data_del_funerale’,
    ‘type’ => ‘date_picker’,
    ‘required’ => 1,
    ‘date_format’ => ‘ddmmyy’,
    ‘display_format’ => ‘dd/mm/yy’,
    ‘first_day’ => 1,
    ),
    array (
    ‘key’ => ‘field_52c830293aa75’,
    ‘label’ => ‘foto del defunto’,
    ‘name’ => ‘foto_del_defunto’,
    ‘type’ => ‘image’,
    ‘required’ => 1,
    ‘save_format’ => ‘object’,
    ‘preview_size’ => ‘medium’,
    ‘library’ => ‘all’,
    ),
    array (
    ‘key’ => ‘field_52c830453aa76’,
    ‘label’ => ”,
    ‘name’ => ”,
    ‘type’ => ‘text’,
    ‘default_value’ => ”,
    ‘placeholder’ => ”,
    ‘prepend’ => ”,
    ‘append’ => ”,
    ‘formatting’ => ‘html’,
    ‘maxlength’ => ”,
    ),
    ),
    ‘location’ => array (
    array (
    array (
    ‘param’ => ‘post_type’,
    ‘operator’ => ‘==’,
    ‘value’ => ‘post’,
    ‘order_no’ => 0,
    ‘group_no’ => 0,
    ),
    ),
    array (
    array (
    ‘param’ => ‘post_type’,
    ‘operator’ => ‘==’,
    ‘value’ => ‘post’,
    ‘order_no’ => 0,
    ‘group_no’ => 1,
    ),
    ),
    ),
    ‘options’ => array (
    ‘position’ => ‘normal’,
    ‘layout’ => ‘no_box’,
    ‘hide_on_screen’ => array (
    ),
    ),
    ‘menu_order’ => 0,
    ));
    }

  • What is your front end code?

  • This is the post where I have inserted the custome fields
    http://www.laruveseonoranze.it/canc/

    This is the screenshot of back-end of the post

    http://www.laruveseonoranze.it/wp-content/uploads/2014/01/custom_field.png

  • Hi @andrianiannalisa

    I hope you have read the documentation and understand that ACF does NOT automatically display any values into your front end theme.

    You need to customize your theme to render the ACF values.

    Please read over the ‘getting started’ docs to help understand how to modify your theme.

    Thanks
    E

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

The topic ‘code in function.php doesn't work’ is closed to new replies.