87 lines
3.2 KiB
PHP
87 lines
3.2 KiB
PHP
<?php
|
|
/**
|
|
* Template part for displaying 3 posts from category "agenda"
|
|
*
|
|
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
|
|
*
|
|
* @package Xarxaprod_theme
|
|
* @used by page.php
|
|
* @shown in : home
|
|
*
|
|
*/
|
|
|
|
?>
|
|
|
|
<section id="agenda" class="agenda ">
|
|
<header>
|
|
<h2><a href="<?php echo site_url() . '/activitats' ;?>"><?php echo esc_html__('Agenda', 'xarxaprod'); ?></a></h2>
|
|
</header>
|
|
<main class="xarxaprod-agenda">
|
|
|
|
<?php
|
|
// https://developer.wordpress.org/reference/functions/get_posts/
|
|
// https://www.advancedcustomfields.com/resources/true-false/
|
|
$agenda_query = new WP_Query(
|
|
array(
|
|
'post_type' => array( 'post' ),
|
|
'post_status' => 'publish',
|
|
'posts_per_page' => '3',
|
|
'tax_query' => array (
|
|
array (
|
|
'taxonomy' => 'category',
|
|
'field' => 'slug',
|
|
'terms' => 'activitats','actividades','agenda','agenda-es'
|
|
)
|
|
),
|
|
'meta_query' => array(
|
|
array ( //filter results older than yesterday
|
|
'key' => 'xxp_agenda_date_end',
|
|
'value' => date("Y-m-d"),
|
|
'compare' => '>=',
|
|
'type' => 'DATE',
|
|
)
|
|
),
|
|
// order by meta agenda_date_end
|
|
'orderby' => 'meta_value',
|
|
'order' => 'ASC',
|
|
)
|
|
);
|
|
?>
|
|
<?php if ( $agenda_query->have_posts() ) : ?>
|
|
<?php while ( $agenda_query->have_posts() ) : $agenda_query->the_post(); ?>
|
|
<div class="xarxaprod-card-each xarxaprod-agenda-info-field">
|
|
<header class="entry-header">
|
|
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark" class="">
|
|
<?php the_title( '<h3 class="entry-title">', '</h3>' ); ?>
|
|
</a>
|
|
</header><!-- .entry-header -->
|
|
<section class="activity-organizer organiza-activitat">
|
|
<?php if( get_field('xxp_agenda_free_text') ): ?>
|
|
<p class="item-xxp-agenda-free-text">
|
|
<?php the_field('xxp_agenda_free_text'); ?>
|
|
</p>
|
|
<?php endif; ?>
|
|
</section>
|
|
<aside class="agenda-date agenda-data">
|
|
<?php if( get_field('xxp_agenda_date_start') || get_field('xxp_agenda_date_start') || get_field('xxp_agenda_free_text') ): ?>
|
|
<p>
|
|
<?php if( get_field('xxp_agenda_date_start') ){ ?>
|
|
<span class="item-xxp-agenda-date-start">el <?php the_field('xxp_agenda_date_start'); ?></span>
|
|
<?php } elseif ( get_field('xxp_agenda_date_end') ){ ?>
|
|
<span class="item-xxp-agenda-date-end">fins al<?php the_field('xxp_agenda_date_end'); ?></span>
|
|
<?php } elseif ( get_field('xxp_agenda_free_text') ){?>
|
|
<span class="item-xxp-agenda-free-text"><?php the_field('xxp_agenda_free_text'); ?></span>
|
|
<?php }; ?>
|
|
</p>
|
|
<?php endif; ?>
|
|
</aside>
|
|
</div>
|
|
<?php endwhile;//end of the loop ?>
|
|
<?php wp_reset_postdata(); ?>
|
|
<?php else : //if no post in query ?>
|
|
<p class="no-content"></p>
|
|
<?php endif; //end query ?>
|
|
|
|
</main>
|
|
</section>
|