PHP Warning: Trying to access array offset on value of type bool in template-tag
-
Hello,
So I have this php warning:[STDERR] PHP Warning: Attempt to read property "post_content" on null in /home/***/domains/***/public_html/wp-content/themes/electro/inc/woocommerce/template-tags.php on line 1311\n [STDERR] PHP Warning: Trying to access array offset on value of type bool in /home/***/domains/***/public_html/wp-content/themes/electro/inc/woocommerce/template-tags.php on line 1315\n [STDERR] PHP Warning: Trying to access array offset on value of type bool in /home/***/domains/***/public_html/wp-content/themes/electro/inc/woocommerce/template-tags.php on line 1316\n [STDERR] PHP Warning: Trying to access array offset on value of type bool in /home/***/domains/***/public_html/wp-content/themes/electro/inc/woocommerce/template-tags.php on line 1317\n [STDERR] PHP Warning: Trying to access array offset on value of type bool in /home/***/domains/***/public_html/wp-content/themes/electro/inc/woocommerce/template-tags.php on line 1320\n
It is about this code:
<div id="<?php echo esc_attr( $wrapper_id ); ?>" class="<?php echo esc_attr( implode( ' ', array_map( 'sanitize_html_class', $wrapper_classes ) ) ); ?>" data-columns="<?php echo esc_attr( $columns ); ?>"> <figure class="electro-wc-product-gallery__wrapper"> <?php $attributes = array( 'title' => $image_title, 'data-large-image' => $full_size_image[0], 'data-large-image-width' => $full_size_image[1], 'data-large-image-height' => $full_size_image[2], ); if ( has_post_thumbnail() ) { $html = '<figure data-thumb="' . get_the_post_thumbnail_url( $post_id, 'shop_thumbnail' ) . '" class="electro-wc-product-gallery__image"><a href="' . esc_url( $full_size_image[0] ) . '">'; $html .= get_the_post_thumbnail( $post_id, 'shop_thumbnail', $attributes ); $html .= '</a></figure>'; } else { $html = '<figure class="electro-wc-product-gallery__image--placeholder">'; $html .= sprintf( '<img src="%s" alt="%s" class="wp-post-image" />', esc_url( wc_placeholder_img_src() ), esc_html__( 'Awaiting product image', 'electro' ) ); $html .= '</figure>'; } echo apply_filters( 'electro_wc_single_product_image_thumbnail_html', $html, get_post_thumbnail_id( $post_id ) ); if ( $attachment_ids ) { foreach ( $attachment_ids as $attachment_id ) { $full_size_image = wp_get_attachment_image_src( $attachment_id, 'full' ); $thumbnail = wp_get_attachment_image_src( $attachment_id, 'shop_thumbnail' ); $thumbnail_post = get_post( $attachment_id ); $image_title = $thumbnail_post->post_content; $attributes = array( 'title' => $image_title, 'data-large-image' => $full_size_image[0], 'data-large-image-width' => $full_size_image[1], 'data-large-image-height' => $full_size_image[2], ); $html = '<figure data-thumb="' . esc_url( $thumbnail[0] ) . '" class="electro-wc-product-gallery__image"><a href="' . esc_url( $full_size_image[0] ) . '">'; $html .= wp_get_attachment_image( $attachment_id, 'shop_thumbnail', false, $attributes ); $html .= '</a></figure>'; echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, $attachment_id ); } } ?>
These codes precisely:
1311: $image_title = $thumbnail_post->post_content; 1315: 'data-large-image' => $full_size_image[0], 1316: 'data-large-image-width' => $full_size_image[1], 1317: 'data-large-image-height' => $full_size_image[2], 1320: $html = '<figure data-thumb="' . esc_url( $thumbnail[0] ) . '" class="electro-wc-product-gallery__image"><a href="' . esc_url( $full_size_image[0] ) . '">';
I know it is in the theme, but the theme makers are not helping me…
So, I need to solve this myself… Can anyone explain to me what the warning means exactly and maybe point me in the right direction to solve this?
I would be very grateful!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘PHP Warning: Trying to access array offset on value of type bool in template-tag’ is closed to new replies.