Sindbad~EG File Manager

Current Path : /home/julesbu/www/dup-installer/wp-content/themes/Jules_Belamy/page-templates/
Upload File :
Current File : /home/julesbu/www/dup-installer/wp-content/themes/Jules_Belamy/page-templates/blog.php

<?php
/*
  Template Name: Blog
*/
?>
<?php get_header(); ?>
<main class="blog">
  <?php $hero = get_field('hero'); ?>
  <section class="blog__hero">
    <img src="<?= get_template_directory_uri(); ?>/assets/images/common/purple-planet.svg" class="hero-image_planet">
    <div class=" container">
      <div class="blog__hero-container">
        <div class="blog__hero-subcontainer">
          <p class="subheading text-purple200">
            <?php echo $hero['surtitle']; ?>
          </p>
          <h1 class="heading-1 text-white font-bold mb-12">
            <?php echo $hero['title']; ?>
          </h1>
          <p class="body-3 text-purple300 mb-32">
            <?php echo $hero['content']; ?>
          </p>
          <div class="blog__form-container">
            <?php $form = $hero['form']; ?>
            <?php echo do_shortcode($form); ?>

          </div>
          <div class="flex gap-8 mt-8">
            <img src="<?php echo get_template_directory_uri(); ?>/assets/images/article/info.svg" class="" />
            <p class="single-article__newsletter-policy">
              Accédez à nos <a href="#">politiques de confidentialité</a>
            </p>
          </div>
        </div>
        <div class="blog__hero-subcontainer">
          <img src="<?php echo $hero['image']; ?>" alt="hero image" class="blog__hero-image">
        </div>
      </div>
    </div>
  </section>
  <section class="blog__section-2">
    <div class="container">
      <div class="flex mb-32 items-center justify-between">
        <div class="blog__section-2-categories ">

          <a href="<?= get_permalink(get_option('page_for_posts')); ?>"
            class="blog__section-2-category <?= !is_category() ? 'active' : ''; ?>">
            Tout
          </a>


          <?php
          $categories = get_categories();
          $current_category = get_queried_object();
          ?>

          <?php foreach ($categories as $category): ?>
            <a href="<?= get_category_link($category->term_id); ?>"
              class="blog__section-2-category <?= (is_category() && $current_category->term_id === $category->term_id) ? 'active' : ''; ?>">
              <?= $category->name; ?>
            </a>
          <?php endforeach; ?>
        </div>
        <?php get_search_form(); ?>
      </div>



      <?php
      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // Récupère la page actuelle
      
      $args = array(
        'post_type' => 'post',
        'posts_per_page' => 1,
        'paged' => $paged,
        'order' => 'DESC',
        'orderby' => 'date'
      );

      $query = new WP_Query($args);
      ?>

      <div class="blog__section-2-items-container">



        <?php if ($query->have_posts()): ?>
          <?php while ($query->have_posts()):
            $query->the_post(); ?>
            <?php $category = get_the_category()[0]; ?>
            <?php $post_reading_time = do_shortcode('[rt_reading_time post_id="' . get_the_ID() . '"]'); ?>

            <article class="blog__section-2-item">
              <a href="<?= get_the_permalink(); ?>" class="blog__section-2-item-container">
                <div class="blog__section-2-item-image-container">
                  <img src="<?= get_the_post_thumbnail_url(); ?>" alt="Article Image" class="blog__section-2-item-image">
                </div>
                <div class="blog__section-2-item-content">
                  <div class="flex items-center justify-between">
                    <p class="body-1 text-purple500 mb-8 blog__section-2-category">
                      <?= $category->name; ?>
                    </p>
                    <div class="flex items-center gap-8 mb-16">
                      <p class="body-1 text-purple800">
                        <svg xmlns="http://www.w3.org/2000/svg" width="17" height="16" fill="none">
                          <path stroke="#180835" stroke-linecap="round" stroke-linejoin="round"
                            d="M8.669 4v4l2.666 1.334m4-1.334A6.667 6.667 0 1 1 2.002 8a6.667 6.667 0 0 1 13.333 0Z" />
                        </svg>
                        <?= $post_reading_time; ?> min
                      </p>
                    </div>
                  </div>
                  <div class="blog__section-2-item-title-container mb-16">
                    <h4 class="blog__section-2-item-title text-purple800">
                      <?= get_the_title(); ?>
                    </h4>
                  </div>
                  <p class="body-1 font-regular text-purple800 mb-24">
                    <?= get_the_excerpt(); ?>
                  </p>
                  <?php if (function_exists('kk_star_ratings')): ?>
                    <div class="blog__section-2-rating">
                      <?php echo kk_star_ratings(get_the_ID()); ?>
                    </div>
                  <?php endif; ?>
                </div>
              </a>
            </article>

          <?php endwhile; ?>
        <?php else: ?>
          <p>Aucun article trouvé.</p>
        <?php endif; ?>
      </div>

      <!-- Pagination -->
      <div class="pagination">
        <?php
        $prev_link = get_previous_posts_link('< Précédent');
        $next_link = get_next_posts_link('Suivant >', $query->max_num_pages);

        if (!$prev_link) {
          echo '<div class="prev-placeholder"></div>';
        } else {
          // echo $prev_link;
        }

        echo paginate_links(array(
          'total' => $query->max_num_pages,
          'current' => max(1, get_query_var('paged')),
          'format' => '?paged=%#%',
          'prev_text' => '< Précédent',
          'next_text' => 'Suivant >',
        ));

        if (!$next_link) {
          echo '<div class="next-placeholder"></div>';
        } else {
          // echo $next_link;
        }
        ?>
      </div>


    </div>
    <?php wp_reset_postdata(); ?>
  </section>
</main>

<?php get_footer(); ?>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists