<?php get_header();
/**
 * Template Name: From Download
 */
$current_language = pll_current_language(); ?>
    <section class=" my-5">
        <div class="faculty-profile-banner d-flex justify-content-center align-items-center text-center"
             style="background-image: linear-gradient(rgb(37 59 128), rgba(1, 39, 11, 0.75)),url(<?php echo get_site_url(); ?>/wp-content/uploads/2024/07/IMG-20240728-WA0000.jpg) ">
            <h1 class="fs-1 fw-bolder text-white font-poppins text-center"><?php echo pll_e('from_download') ?></h1>
        </div>
    </section>
    <main class="container">
        <section>
            <div class="container">
                <div class="row">

                    <?php
                    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                    $args = array(
                        'post_type' => 'download',
                        'posts_per_page' => 10,
                        'paged' => $paged,
                        'lang' => $current_language
                    );
                    $loop = new WP_Query($args);
                    $post = $loop->have_posts();
                    while ($loop->have_posts()) {
                        $loop->the_post();


                        get_template_part('template/notice_page', get_post_format());
                    }
                    ?>


                </div>

                <div class="row ">
                    <div class="col-sm-12 news-pagination">
                        <nav>
                            <?php
                            $big = 999999999; // need an unlikely integer
                            $total_pages = $loop->max_num_pages;

                            if ($total_pages > 1) {
                                $current_page = max(1, get_query_var('paged'));

                                $pages = paginate_links(array(
                                    'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
                                    'format' => '?paged=%#%',
                                    'current' => $current_page,
                                    'total' => $total_pages,
                                    'type' => 'array',
                                    'prev_text' => __('« Previous', 'textdomain'),
                                    'next_text' => __('Next »', 'textdomain'),
                                ));

                                if (is_array($pages)) {
                                    echo '<ul class="pagination">';
                                    foreach ($pages as $page) {
                                        // Add 'page-link' class to each pagination link
                                        echo "<li class='page-item'>" . str_replace('page-numbers', 'page-numbers page-link', $page) . "</li>";
                                    }
                                    echo '</ul>';
                                }
                            }
                            ?>

                        </nav>

                    </div>
                </div>
            </div>
        </section>

    </main>
    <!-- Content Here -->
<?php get_footer(); ?>