Support » Fixing WordPress » Warning: Illegal string offset ‘id’

  • Anonymous User 17720056

    (@anonymized-17720056)


    Hi! I’ve been trying to find a fix to this problem without any results. Does someone know what I should change in our code in order to get rid of the warning message?

    `Warning: Illegal string offset ‘id’ in /home/customer/www/anielaparys.com/public_html/wp-content/themes/aniela-parys/about.php on line 11

    Warning: Illegal string offset ‘link_url’ in /home/customer/www/anielaparys.com/public_html/wp-content/themes/aniela-parys/about.php on line 11

    Warning: Cannot assign an empty string to a string offset in /home/customer/www/anielaparys.com/public_html/wp-content/themes/aniela-parys/about.php on line 11`

    Our code:

    <?php
    // Template Name: About

    do_action( ‘get_header’ );

    require_once ‘partials/site-common.php’;

    $images = get_field(‘gallery’);
    if ( $images ) {
    for ( $i=0; $i<count($images); $i++) {
    $images[$i][‘link_url’] = get_field(‘link_url’, $images[$i][‘id’]);
    }
    }

    $context[‘left_info’] = get_field( ‘left_info’ );
    $context[‘contact_information’] = get_field( ‘contact_information’ );

    //$footer_menu_id = get_term_by( ‘slug’, ‘footer’, ‘nav_menu’ )->term_id;
    //$context[‘footer’] = new TimberMenu( $footer_menu_id );

    Timber::render( ‘about.twig’, $context );

    do_action( ‘get_footer’ );

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • It just means

    $images[$i]['id']

    That there is no element ‘id’ in the $images array

    nor

    $images[$i][‘link_url’]

    has a ‘link_url’

    you really need to inspect the content of the $images array to see what is actually there

    Thread Starter Anonymous User 17720056

    (@anonymized-17720056)

    Thank you for your response Alan! I didn’t build this website and can’t get in touch with the theme developers so I’m stuck trying to figure out what to do next.

    Do you have an idea where I should start looking concerning the $images array?

    Normally you would debug using a debugging tool (IDE).

    But assuming you don’t know your way around code, you may be stuck without a developer.

    But before you go down that route: does the site work as expected apart from the Warning?. Because Warnings are not an error as such – but may indicate an issue, now or in the future.

    If it is working apart from the Warnings, you can simply hide the warnings.

    See https://fullworks.net/docs/plugins-general/troubleshooting-plugins-general/php-notices-and-warnings/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Warning: Illegal string offset ‘id’’ is closed to new replies.