Author

<?php

  /**
  * A Simple Category Template
  */

  get_header(); 

?>

<main id="primary" class="site-main category">

  <!-- MENÚ  -->
  <?php include("template-parts/menu.php") ?>

  <!-- HERO  -->
  <section id="idHero">
    <div class="contenedor-seccion container-fluid">
      <div class="contenedor-interno container">
        <!-- TÍTULO SECCIÓN  -->
        <div class="titulo-seccion">
          <?php
            $author = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
          ?>

          <h1><?php echo $author->display_name?></h1>
           <div class="separador">
            <hr>
           </div>
           <div class="icono">
             <img src="<?php echo get_stylesheet_directory_uri()?>/img/iconos/arrow-right.svg">
           </div>
        </div>
  
        <!-- ÚLTIMO POST  -->
        <div class="ultimo-post">
          <?php 
            $args = array(
              'posts_per_page' => 1, /* how many post you need to display */
              'offset' => 0,
              'orderby' => 'post_date',
              'order' => 'DESC',
              'post_type' => 'post', /* your post type name */
              'post_status' => 'publish',
              'author' => $author->ID,
            );
            $query = new WP_Query($args);
            if ($query->have_posts()) :
                while ($query->have_posts()) : $query->the_post();
                    ?>
  
                    <!-- DATA  -->
                    <div class="data">
                      <span class="fecha"><?php the_date() ?></span>
                      <a href="<?php the_author_meta('url') ?>" class="autor"><?php the_author_meta('display_name')?></a>
                      <a class="titulo" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                      <button><a href="<?php the_permalink(); ?>">Leer nota</a></button>
                        
                    </div>
                      
                    <!-- FOTO  -->
                    <div class="foto">
                      <a class="foto" rel="external" href="<?php echo get_permalink()?>"><img src="<?php the_post_thumbnail_url()?>" alt="Ir al post"></a>
                    </div>
  
                    
                    <?php
                endwhile;
            endif;
          ?>
          
        </div>
      </div>
    </div>
  </section>
  
  <!-- POSTEOS  -->
  <section id="idPosteos">
    <div class="contenedor-seccion container">
      <ul class="listado">

        <?php
        // Check if there are any posts to display
        if ( have_posts() ) : ?>
      
        <?php
      
          // The Loop
          while ( have_posts() ) : the_post();?>
            <li class="post-query" data-aos="fade-up" data-aos-duration="1000">
              <a class="foto" rel="external" href="<?php echo get_permalink()?>"><img src="<?php the_post_thumbnail_url()?>" alt="Ir al post"></a>

              <span class="fecha"><?php the_date() ?></span>

              <a class="titulo" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
              
              <p class="autor">Por <a href="<?php the_author_meta('url') ?>" class="autor"><?php the_author_meta('display_name')?></a> </p>
            
              <!-- <p class=”postmetadata”><?php
              comments_popup_link( 'No comments yet', '1 comment', '% comments', 'comments-link', 'Comments closed');
              ?></p> -->
            </li>
        
          <?php endwhile; // End Loop
      
        endif; ?>
      </ul>  
    </div>
  </section>

  <!-- PRE FOOTER  -->
  <section id="idPreFooter">
    <div class="contenedor-seccion container-fluid">
      <div class="contenedor">
        <div class="imagen">
          <?php
            $field = get_field('personajes_footer','option');
            $url = $field['newsletters'];
            echo "<img src='$url' alt='Imagen ilustrativa'>";
          ?>
        </div>
        <div class="formulario">
          <div class="titulo">
            <h4>¡Suscribite a Uganda!</h4>
          </div>
          <iframe src="https://uganda.substack.com/embed" width="380" height="380" id="idFooterFrame" style="border:none; background:transparent;" frameborder="0" scrolling="no"></iframe>
        </div>
      </div>
    </div>
  </section>

  <!-- BANNER HORIZONTAL  -->
  <?php include("template-parts/banner-horizontal-2.php") ?>
</main>

<script>
  let postEven = document.querySelectorAll(".post-query:nth-child(even)");
  postEven.forEach(post => {
  post.dataset.aosDelay = "200"; 
  });

  let post1 = document.querySelector(".post-query:nth-child(1)");
  post1.dataset.aos = " ";

  let post2 = document.querySelector(".post-query:nth-child(2)");
  post2.dataset.aos = " "; 
  
</script>


<?php get_sidebar(); ?>
<?php get_footer(); ?>