Support

Account

Home Forums Front-end Issues Links in repeater field not showing in front-end

Unread

Links in repeater field not showing in front-end

  • I have a link as part of a repeater field but when i upload the code to my server the links don’t appear. The work when running my site locally with MAMP pro.

    Using version: Version 5.11.1

    The error log on the serve shows:
    [Fri Nov 19 16:47:02.486684 2021] [php:warn] [pid 2134] [client ] PHP Warning: Trying to access array offset on value of type bool in /var/www/html/wp-content/themes/websirTwentyTwentyOne/template-parts/c2a.php on line 23, referer: https://dev.shiulirestaurant.com/

    Page with issue:
    https://dev.shiulirestaurant.com/menus/

    Just above footer
    This is an exports of the ACF.

    `
    if( function_exists(‘acf_add_local_field_group’) ):

    acf_add_local_field_group(array(
    ‘key’ => ‘group_6197c1afadd4c’,
    ‘title’ => ‘Call to Actions’,
    ‘fields’ => array(
    array(
    ‘key’ => ‘field_6197c1c23c7cd’,
    ‘label’ => ‘Call to Actions’,
    ‘name’ => ‘call_to_actions’,
    ‘type’ => ‘repeater’,
    ‘instructions’ => ”,
    ‘required’ => 0,
    ‘conditional_logic’ => 0,
    ‘wrapper’ => array(
    ‘width’ => ”,
    ‘class’ => ”,
    ‘id’ => ”,
    ),
    ‘collapsed’ => ‘field_6197c1e63c7ce’,
    ‘min’ => 0,
    ‘max’ => 2,
    ‘layout’ => ‘block’,
    ‘button_label’ => ‘Add Call to Action’,
    ‘sub_fields’ => array(
    array(
    ‘key’ => ‘field_6197c1e63c7ce’,
    ‘label’ => ‘Text’,
    ‘name’ => ‘text’,
    ‘type’ => ‘text’,
    ‘instructions’ => ”,
    ‘required’ => 1,
    ‘conditional_logic’ => 0,
    ‘wrapper’ => array(
    ‘width’ => ”,
    ‘class’ => ”,
    ‘id’ => ”,
    ),
    ‘default_value’ => ”,
    ‘placeholder’ => ”,
    ‘prepend’ => ”,
    ‘append’ => ”,
    ‘maxlength’ => ”,
    ),
    array(
    ‘key’ => ‘field_6197c20a3c7cf’,
    ‘label’ => ‘Link’,
    ‘name’ => ‘link’,
    ‘type’ => ‘link’,
    ‘instructions’ => ”,
    ‘required’ => 1,
    ‘conditional_logic’ => 0,
    ‘wrapper’ => array(
    ‘width’ => ”,
    ‘class’ => ”,
    ‘id’ => ”,
    ),
    ‘return_format’ => ‘array’,
    ),
    array(
    ‘key’ => ‘field_6197c21f3c7d0’,
    ‘label’ => ‘Image’,
    ‘name’ => ‘image’,
    ‘type’ => ‘image’,
    ‘instructions’ => ”,
    ‘required’ => 1,
    ‘conditional_logic’ => 0,
    ‘wrapper’ => array(
    ‘width’ => ”,
    ‘class’ => ”,
    ‘id’ => ”,
    ),
    ‘return_format’ => ‘array’,
    ‘preview_size’ => ‘medium’,
    ‘library’ => ‘all’,
    ‘min_width’ => ”,
    ‘min_height’ => ”,
    ‘min_size’ => ”,
    ‘max_width’ => ”,
    ‘max_height’ => ”,
    ‘max_size’ => ”,
    ‘mime_types’ => ”,
    ),
    array(
    ‘key’ => ‘field_6197c22b3c7d1’,
    ‘label’ => ‘Opacity’,
    ‘name’ => ‘opacity’,
    ‘type’ => ‘range’,
    ‘instructions’ => ”,
    ‘required’ => 1,
    ‘conditional_logic’ => 0,
    ‘wrapper’ => array(
    ‘width’ => ”,
    ‘class’ => ”,
    ‘id’ => ”,
    ),
    ‘default_value’ => 0,
    ‘min’ => ”,
    ‘max’ => 1,
    ‘step’ => ‘.1’,
    ‘prepend’ => ‘0-1’,
    ‘append’ => ”,
    ),
    array(
    ‘key’ => ‘field_6197c7648e442’,
    ‘label’ => ‘Text Color’,
    ‘name’ => ‘text_color’,
    ‘type’ => ‘color_picker’,
    ‘instructions’ => ”,
    ‘required’ => 1,
    ‘conditional_logic’ => 0,
    ‘wrapper’ => array(
    ‘width’ => ”,
    ‘class’ => ”,
    ‘id’ => ”,
    ),
    ‘default_value’ => ‘#FFFFFF’,
    ‘enable_opacity’ => 0,
    ‘return_format’ => ‘string’,
    ),
    ),
    ),
    ),
    ‘location’ => array(
    array(
    array(
    ‘param’ => ‘page_template’,
    ‘operator’ => ‘==’,
    ‘value’ => ‘page-template-menu.php’,
    ),
    ),
    ),
    ‘menu_order’ => 0,
    ‘position’ => ‘normal’,
    ‘style’ => ‘default’,
    ‘label_placement’ => ‘top’,
    ‘instruction_placement’ => ‘label’,
    ‘hide_on_screen’ => ”,
    ‘active’ => true,
    ‘description’ => ”,
    ‘show_in_rest’ => 0,
    ));

    endif;
    `

    Code:
    `
    <?php if ( have_rows(‘call_to_actions’) ): ?>
    <section id=”call-to-actions”>

    <?php

    while ( have_rows(‘call_to_actions’) ): the_row();

    $text = get_sub_field(‘text’);
    $link = get_sub_field(‘link’);
    $link_target = $link[‘target’] ? $link[‘target’] : ‘_self’;
    $image = get_sub_field(‘image’);
    $opacity = get_sub_field(‘opacity’);
    $color = get_sub_field(‘text_color’);

    ?>

    <div class=”call-to-action” style=”background-image:url(<?= $image[‘url’]; ?>); –opacity:<?= $opacity; ?>; –c2a-color:<?= $color; ?>;”>

    <div class=”wrap”>

    <h3><?= $text; ?></h3>

    <a href=”<?= $link[‘url’]; ?>” title=”<?= $link[‘title’]; ?>” target=”<?= $link_target; ?>” class=”btn”><?= $link[‘title’]; ?></a>

    </div>

    </div>

    <?php endwhile; ?>

    </section>
    <?php endif; ?>
    `

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.