<?php
/**
 * Posts archive page
 *
 */
inoby_enqueue_parted_style("post", "post_types");
inoby_enqueue_parted_script("post", "post_types");

$categories = get_categories([
  "hide_empty" => apply_filters("inoby_post_archive_hide_empty_categories", false),
  "exclude" => apply_filters("inoby_post_archive_exclude_categories", [1]), // [1] will exclude uncategorized from query
]);

$category_id = get_query_var("cat", false);

$active_category = $category_id ? get_category($category_id) : null;

get_header();
?>
<main id="primary" class="site-main">
  <section class="header">
    <div class="container">
      <?php do_action('blog_archive_header_before_heading') ?>
      <h1><?= post_type_archive_title(null, false) ?? ($active_category->name ?? "") ?></h1>
      <?php
      if(Inoby_Config::latest_posts() > 0){
        get_template_part("post-types/post/parts/featured-posts-list"); 
      }
      ?>
    </div>
  </section>

  <section class="filter">
    <div class="container">
      <?php get_template_part("post-types/post/parts/category-filter", null, compact("categories", "active_category")); ?>
    </div>
  </section>

  <section class="list">
    <div class="container">
      <?php get_template_part("post-types/post/parts/posts-list"); ?>
    </div>
  </section>

  <section class="pagination">
    <div class="container">
      <?php get_template_part("post-types/post/parts/pagination"); ?>
    </div>
  </section>
</main>

<?php get_footer();