When upgrading php from php 7.4 to php 8.0 an error generally comes which says – “Error Trying to access array offset on value of type bool” .
There is a very simple fixes for this error.
Check for the mentioned file and the line and check for the array valiable.
This error comes when we use array offset which is not having any value i.e false. To remove this error we need to add a check for the value in this array variable like below:
$featured_img_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full'); if( $featured_img_url ){ $thumb_url = $featured_img_url[0]; }else{ $thumb_url = ''; }
Modify your codes according to this sample codes.
Hope this will solve the issue. If you still face the issue let us know.
Some important study notes
Excellent
These codes can also be used for adding featured image in the page
$featured_img_url = wp_get_attachment_image_src( get_post_thumbnail_id(), ‘full’);
if( $featured_img_url ){
$thumb_url = $featured_img_url[0];
}else{
$thumb_url = ”;
}
echo $thumb_url; // to display featured image in the page
Yes you are correct. Thanks for your comments