xarxaprod-wp-theme/template-parts/section-last-agenda.php

92 lines
3.4 KiB
PHP
Raw Normal View History

2024-02-22 18:42:56 +01:00
<?php
/**
* Template part for displaying 3 posts from category "agenda"
2024-02-22 18:42:56 +01:00
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Xarxaprod_theme
* @used by page.php
* @shown in : home
*
2024-02-22 18:42:56 +01:00
*/
?>
<section id="agenda" class="agenda ">
2024-02-22 18:42:56 +01:00
<header>
<h2><a href="<?php echo site_url() . '/activitats' ;?>"><?php echo esc_html__('Agenda', 'xarxaprod'); ?></a></h2>
2024-02-22 18:42:56 +01:00
</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',
2024-02-27 11:17:55 +01:00
'terms' => 'activitats','actividades','agenda','agenda-es'
2024-02-22 18:42:56 +01:00
)
),
'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',
)
);
2024-02-22 18:42:56 +01:00
?>
<?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_who') ): ?>
<?php $allwhoproposes = get_field('xxp_agenda_who'); ?>
<p class="item-xxp-agenda-who">
<?php
foreach( $allwhoproposes as $eachwhoproposes ):
echo $eachwhoproposes['label'];
endforeach;
?>
</p>
<?php endif; ?>
2024-02-22 18:42:56 +01:00
</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; ?>
2024-02-22 18:42:56 +01:00
</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>