I'm beginner in php and wordpress and I'm trying convert html template to wordpress theme and i face this issue :
Warning: Trying to access array offset on value of type bool in E:\xampp\htdocs\consulty\wp-content\themes\consulty\template-parts\content-gallery.php on line 13
I got the php code from the link above the code for creating gallery post format in index.php page
<?php
/**
* -- Gallery Post Format
* https://stackoverflow.com/questions/48535908/customizing-wordpress-gallery-post-format
*/
if ( has_post_format( 'gallery' ) ) {
?>
<div id="post-<?php the_ID(); ?>" <?php post_class('gallery'); ?>>
<?php
$gallery = get_post_gallery( $post, false );
$att_ids = wp_parse_id_list( $gallery['ids'] ); //***This is line 13***
?>
<div class="inner-box">
<div id="post-gallery-<?php the_ID(); ?>"
<?php post_class('news-carousel owl-carousel owl-theme owl-dots-none'); ?>>
<?php
for ( $i = 0; $i < count( $gallery['src'] ); $i++ ) {
?>
<figure class="image-box">
<img class="" src="<?php echo esc_url( $gallery['src'][ $i ] ); ?>" />
<span class="category"><?php the_category( ', ' ); ?></span>
</figure>
<?php } ?>
</div><!-- /.news-carousel owl-carousel owl-theme owl-dots-none -->
<div class="lower-content">
<ul class="post-info clearfix">
<li>
<i class="far fa-user"></i><a
href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>"><?php the_author(); ?></a>
</li>
<li><i class="far fa-calendar-alt"></i><?php the_time('F jS, Y') ?></li>
<li><i class="far fa-comment-alt"></i>
<?php //comments_popup_link();
comments_popup_link( 'No Comment', '1 Comment', '% Commentston', '', 'Comments Off' );
?>
</li>
<li>
<i class="far fa-folder"></i>
<?php
$categories = get_the_category();
$separator = ', ';
$output = '';
if ( $categories ) {
foreach ( $categories as $category) {
$output .= '<a href="' . get_category_link( $category->term_id ) . '">' . $category->cat_name . '</a>' . $separator;
}
echo trim($output, $separator);
}
?>
</li>
</ul>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p>
<?php the_excerpt(); ?>
</p>
<div class="read-more-link">
<a href="<?php the_permalink(); ?>">
<i class="fas fa-arrow-right"></i>
<span><?php _e('Read More'); ?></span>
</a>
</div>
</div><!-- /.lower-content -->
</div><!-- /.inner-box -->
</div>
<?php } ?>
What this mean and how to fix it?
Thank you