I am getting a couple of errors with some code I cannot seem to get worked out. I am running WP 6.1 and php 8.1.
Errors are
\[05-Nov-2022 15:15:21 UTC\] PHP Warning: Trying to access array offset on value of type bool in /home/xxxx/public\_html/xxxx.xxx/wp-content/themes/my-portfolio/template-about.php on line 4 (code from this file below)
1. <?php get_header(); ?>
2.
3. <?php
4. $aboutImage = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), ‘full’)[0];
5. if (!$aboutImage) {
6. $aboutImage = get_template_directory_uri() . ‘/assets/img/default.jpg’;
7. }
8. ?>
9. <!– Section 1 –>
10. <section class=”container mb-5″ id=”bio”>
11. <a href=”<?php echo home_url(‘/’) ?>”>
12. <img src=”<?php echo get_template_directory_uri() ?>/assets/img/arrow-back.png” width=”40px” height=”40px” />
13. </a>
14. </section>
\[05-Nov-2022 15:15:23 UTC\] PHP Warning: Trying to access array offset on value of type bool in /home/xxxx/public\_html/xxxx.xxx/wp-content/themes/my-portfolio/template-parts/content-default.php on line 532
\[05-Nov-2022 15:15:23 UTC\] PHP Warning: Trying to access array offset on value of type bool in /home/xxxx/public\_html/xxxx.xxx/wp-content/themes/my-portfolio/template-parts/content-default.php on line 532 (code from this file below)
494. <!– Achievements Type – Certifications –>
495. <section class=”container” id=”achievements”>
496. <div class=”row”>
497. <div class=”head”>
498. <h2>Certifications</h2>
499. </div>
500. </div>
501.
502. <?php if (empty($certifications)) : ?>
503. <div class=”row g-4″>
504. <?php for ($i = 0; $i < 4; $i++) : ?>
505. <div class=”col-md-6″>
506. <div class=”card”>
507. <img src=”<?php echo get_template_directory_uri() ?>/assets/img/example.jpg” class=”card-img-top” alt=”…” />
508. <h5>Title</h5>
509. </div>
510. </div>
511. <?php endfor; ?>
512. </div>
513. <?php else : ?>
514. <div class=”row g-4″>
515. <?php foreach ($certifications as $key => $certification) : ?>
516. <?php
517. if ($key > 3) {
518. continue;
519. }
520. ?>
521. <?php
522. $type = get_post_meta($certification->ID, ‘achievement_type’, true) ?? ‘certification’;
523. $url = get_post_meta($certification->ID, ‘certification_url’, true) ?? ‘#’;
524. ?>
525. <?php
526. $order = get_post_meta($certification->ID, ‘order_main’, true);
527. $order = $order ? $order : 5;
528. ?>
529. <div class=”col-md-6″ style=”order:<?= $order ?>”>
530. <a href=”<?php echo $url ?>” target=”_blank”>
531. <div class=”card”>
532. <img src=”<?php echo wp_get_attachment_image_src(get_post_thumbnail_id($certification->ID), ‘single-post- thumbnail’)[0]; ?>” class=”card-img-top” alt=”…” />
533. <h5><?= $certification->post_title ?></h5>
534. </div>
535. </a>
536. </div>
537. <?php endforeach; ?>
538. </div>
539. <?php if (count($certifications) > 4) : ?>
540. <div class=”learn-more”>
541. <a href=”<?php echo home_url(‘/?p=certification’) ?>” class=”btn btn-primary”>See More</a>
542. </div>
543. <?php endif; ?>
544. <?php endif; ?>
545. </section>
