Warning: Trying to access array offset on value of type null in /var/www/u2016481/data/www/miostagroup.com/wp-content/themes/miosta/page-articles.php on line 32
but my code is
if (!defined('ABSPATH')) {
die();
}
$id = get_the_ID();
$event = get_field('content', $id);
/// print_r($home);
?>
<?php get_header(); ?>
<main class="main" data-page="home" id="smooth-content">
<!-- header -->
<?php get_template_part('template-parts/header/header_main'); ?>
<div class="main__wrap">
<div class="events__cover">
<div class="events__cover-content activation">
<h2 class="cover__content-title title__logo title__logo--57">
32 line <?php echo preg_replace("#*{2}(.*?)*{2}#", "<sup>$1</sup>", $event['title']); ?>
</h2>
<h1 class="cover__content-title title__logo title__logo--90">
<?php echo get_the_title($id); ?>
</h1>
</div>
<span class="events__cover-circle activation"></span>
<span class="events__cover-circle activation events__cover-circle--type2"></span>
</div>
<section class="events__content">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query = new WP_Query(array(
'post_type' => 'post',
'posts_per_page' => 6,
'paged' => $paged
));
if ($query->have_posts()) {
?>
<div class="events__grid activation">
<?php foreach ($query->posts as $k) { ?>
<?php
$field = get_field('content', $k->ID);
$year = date('j F Y', strtotime($k->post_date));
?>
<div class="events__card" itemscope itemtype="http://schema.org/Event">
<div class="events__card-photo">
<picture>
<?php if (isset($field['img_prev']) && $field['img_prev']) { ?>
<?php echo avif_convert($field['img_prev']); ?>
<img class="events__card-img active" src="<?php echo $field['img_prev']['sizes']['medium']; ?>" alt="<?php echo ($field['img_prev']['alt'] ?? ""); ?>" data-tab="h" itemprop="image">
<?php } //end if
?>
</picture>
</div>
<div class="events__card-content">
<span class="events__card-date" itemprop="startDate"><?php echo month_translate($year); ?></span>
<h2 class="events__card-title" itemprop="name"><?php echo ($k->post_title ?? ""); ?></h2>
<a class="button main__products-link active" href="<?php echo get_permalink($k->ID); ?>" itemprop="url">
<span class="button__mask2"><?php pll_e('Подробнее'); ?></span>
</a>
</div>
</div>
<?php } //end foreach
?>
</div>
<div class="events__pagi">
<?php
$big = 999999999; // Число, которое гарантированно больше числа всех страниц
$pagination = paginate_links(array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'show_all' => true,
'prev_next' => false,
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $query->max_num_pages,
'type' => 'array',
));
if ($pagination !== null) {
?>
<a class="events__pagi-btn" href="<?php echo get_previous_posts_page_link(); ?>" aria-label="Предыдущая страница">
<svg width="18" height="7">
<use xlink:href="#icon-pagi-left">
</use>
</svg>
</a>
<ul class="events__pagi-list">
<?php
foreach ($pagination as $page) {
$page = str_replace('page-numbers', 'events__pagi-link', $page);
if (strpos($page, 'current')) {
$page = str_replace('current', 'active', $page);
echo '<li class="events__pagi-item">' .
$page
. '</li>';
} else {
echo '<li class="events__pagi-item">' .
$page
. '</li>';
}
}
?>
</ul>
<a class="events__pagi-btn next" href="<?php echo get_next_posts_page_link(); ?>" aria-label="Следующая страница">
<svg width="18" height="7">
<use xlink:href="#icon-pagi-right">
</use>
</svg>
</a>
<?php } //end if $pagination null
?>
</div>
<?php } //end if $query
?>
<span class="events__grid-circle"></span>
</section>
</div>
<!-- footer -->
<?php get_template_part('template-parts/footer/footer_main'); ?>
</main>
<?php get_footer(); ?>
What is wrong
It is a cooperated code from other web page with the same meaning is the same as in the other,but I have to do some kind of information
I did not understand what I need to do could you help me please?