<?php get_header(); ?>
<div class="container content content--single">
<?php ege_breadcrumbs(); ?>
<?php if(have_posts()):while(have_posts()):the_post(); ?>
<article class="post-entry">
  <header class="post-entry__header">
    <p class="post-entry__subject">Русский язык • ОГЭ 2026</p>
    <h1><?php the_title(); ?></h1>
  </header>
  <div class="post-entry__content">
    <?php the_content(); ?>
  </div>

  <?php
    $related_posts = new WP_Query([
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 6,
      'orderby' => 'rand',
      'ignore_sticky_posts' => true,
      'post__not_in' => [get_the_ID()],
      'no_found_rows' => true,
    ]);
  ?>

  <?php if ($related_posts->have_posts()) : ?>
    <aside class="related-links" aria-label="Другие записи">
      <h2 class="related-links__title">Другие записи по русскому языку</h2>
      <ul class="related-links__list">
        <?php while ($related_posts->have_posts()) : $related_posts->the_post(); ?>
          <li class="related-links__item">
            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
          </li>
        <?php endwhile; ?>
      </ul>
    </aside>
  <?php endif; ?>

  <?php wp_reset_postdata(); ?>
</article>
<?php endwhile;endif; ?>
</div>
<?php get_footer(); ?>