<?php
/**
 * Template Name: Publications
 *
 * @package gralbcn
 */

get_header(); ?>
<div class="container grid">




			
	


<div class="publications-page">
  <h2>—Publications</h2>

  <div class="publications-list">
    <?php
    $publications = new WP_Query(array(
	'post_type' => 'post',
	'posts_per_page' => -1,
	'category_name' => 'publications',
	'orderby' => array(
		'menu_order' => 'ASC',
		'post_title' => 'ASC'
	)
	));

    if ($publications->have_posts()) :
      $count = 0;
      while ($publications->have_posts()) : $publications->the_post();
        $authors = get_field('authors');
        $year = get_field('year');
        $theme = get_field('theme');
        $edition = get_field('edition');

        $hidden_class = ($count >= 2) ? 'hidden' : '';

        ?>
       <p class="publication-item <?php echo $hidden_class; ?>">
		<?php
		echo esc_html($authors) . ' (' . esc_html($year) . '). ';
		echo '<span class="blue">' . get_the_title() . '</span>. ';
		echo esc_html($theme) . ', ' . esc_html($edition);
		?>
		</p>

        <?php
        $count++;
      endwhile;
      wp_reset_postdata();
    else:
      echo '<p>No publications found.</p>';
    endif;
    ?>
  </div>

  <?php if ($count > 2): ?>
	<div class="container-center-button">
   		 <button id="view-more-btn" class="btn btn-primary">View more</button>
  </div>	 
  <?php endif; ?>

</div>









</div> <!-- end container -->








<?php get_footer(); ?>