2024-02-20 23:13:06 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2024-02-22 18:42:34 +01:00
|
|
|
* Template part for displaying "convos" and widgets
|
2024-02-20 23:13:06 +01:00
|
|
|
*
|
|
|
|
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
|
|
|
|
*
|
|
|
|
* @package Xarxaprod_theme
|
|
|
|
*/
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
2024-02-29 12:04:10 +01:00
|
|
|
<section id="convos" class="last-convos ultimes-convocatories">
|
2024-02-20 23:13:06 +01:00
|
|
|
<?php
|
|
|
|
// Detect plugin. For use on Front End only.
|
|
|
|
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
|
|
|
// check for plugin using plugin name
|
|
|
|
if ( is_plugin_active( 'xarxaprod-wp-plugin/xarxaprod-wp-plugin.php' ) ) {
|
|
|
|
//plugin is activated do
|
|
|
|
?>
|
|
|
|
<header>
|
2024-03-12 23:33:12 +01:00
|
|
|
<?php //begin any query
|
2024-03-13 19:41:07 +01:00
|
|
|
// begin populate WP_Query if is custom post type xarxaprod-associat
|
2024-03-12 23:33:12 +01:00
|
|
|
if ( get_post_type( ) == 'xarxaprod-associat' ){
|
|
|
|
$slug_espai_associat =get_post_field( 'post_name', get_post() ) ;
|
|
|
|
// https://developer.wordpress.org/reference/functions/get_posts/
|
|
|
|
// query ACF relationsihp
|
|
|
|
// https://wordpress.stackexchange.com/a/213375
|
|
|
|
$convos_query = new WP_Query(
|
|
|
|
array(
|
|
|
|
'post_type' => 'xarxaprod-convo',
|
|
|
|
'posts_per_page' => '3',
|
2024-03-13 19:41:07 +01:00
|
|
|
'order_by' => 'meta_value', //order by meta value
|
|
|
|
'meta_key' => 'xxp_convo_apply_end', // order by meta key convo apply end
|
|
|
|
'order' => 'ASC', //order ascendent
|
2024-03-12 23:33:12 +01:00
|
|
|
'meta_query' => array(
|
2024-03-13 19:41:07 +01:00
|
|
|
array( //filter results show today and later
|
|
|
|
'key' => 'xxp_convo_apply_end',
|
|
|
|
'value' => date("Y-m-d"), // consider using date_i18n() https://developer.wordpress.org/reference/functions/date_i18n/
|
|
|
|
'compare' => '>=', //show events today and later
|
|
|
|
'type' => 'DATE',
|
|
|
|
),
|
|
|
|
array( //filter convos with relation to espai associat
|
2024-03-12 23:33:12 +01:00
|
|
|
'key' => 'xxp_convo_espai_associat', // name of the custom field
|
|
|
|
'value' => '"' . get_the_ID() . '"', // in ACF select Return format "Post ID"
|
|
|
|
'compare'=> 'LIKE', // matches exaclty "123", not just 123. This prevents a match for "1234"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
?>
|
2024-04-01 11:05:33 +02:00
|
|
|
<h2> <a href="<?php echo home_url( '/convos/?xxp_convo_center=' ) . $slug_espai_associat ;?>"><?php echo esc_html__('Últimes convocatòries', 'xarxaprod'); ?> de <?php the_title(); ?></a></h2>
|
2024-03-12 20:23:55 +01:00
|
|
|
</header>
|
|
|
|
<main class="xarxaprod-last-convos xarxaprod-ultimes-convocatories">
|
2024-03-12 23:33:12 +01:00
|
|
|
<?php } //end populate WP_Query custom post type xarxaprod-associat
|
2024-03-13 19:41:07 +01:00
|
|
|
else { // begin populate WP_Query if others
|
2024-03-12 20:23:55 +01:00
|
|
|
// https://developer.wordpress.org/reference/functions/get_posts/
|
|
|
|
// https://www.advancedcustomfields.com/resources/true-false/
|
2024-03-13 19:41:07 +01:00
|
|
|
$convos_query = new WP_Query(
|
|
|
|
array(
|
|
|
|
'post_type' => 'xarxaprod-convo',
|
|
|
|
'posts_per_page' => '3',
|
|
|
|
'order_by' => 'meta_value', //order by meta value
|
|
|
|
'meta_key' => 'xxp_convo_apply_end', // order by meta key convo apply end
|
|
|
|
'order' => 'ASC', //order ascendent
|
|
|
|
'meta_query' => array(
|
|
|
|
array( //filter results show today and later
|
|
|
|
'key' => 'xxp_convo_apply_end',
|
|
|
|
'value' => date("Y-m-d"), // consider using date_i18n() https://developer.wordpress.org/reference/functions/date_i18n/
|
|
|
|
'compare' => '>=', //show events today and later
|
|
|
|
'type' => 'DATE',
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2024-03-12 23:33:12 +01:00
|
|
|
?>
|
2024-03-10 13:22:11 +01:00
|
|
|
<h2> <a href="<?php echo site_url() . '/convocatories' ;?>"><?php echo esc_html__('Últimes convocatòries', 'xarxaprod'); ?></a></h2>
|
2024-02-20 23:13:06 +01:00
|
|
|
</header>
|
|
|
|
<main class="xarxaprod-last-convos xarxaprod-ultimes-convocatories">
|
2024-03-12 23:33:12 +01:00
|
|
|
<?php }; //end populate WP_Query with others ?>
|
|
|
|
<?php //begin loop WP_Query ?>
|
2024-02-22 18:42:34 +01:00
|
|
|
<?php if ( $convos_query->have_posts() ) : ?>
|
|
|
|
<?php while ( $convos_query->have_posts() ) : $convos_query->the_post(); ?>
|
2024-02-20 23:13:06 +01:00
|
|
|
|
|
|
|
<div class="xarxaprod-card-each xarxaprod-convo-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 -->
|
|
|
|
|
2024-02-22 23:20:46 +01:00
|
|
|
<?php if( get_field('xxp_convo_apply_begin') || get_field('xxp_convo_apply_end') ): ?>
|
2024-02-20 23:13:06 +01:00
|
|
|
|
2024-03-30 14:29:34 +01:00
|
|
|
<h6 class="xarxaprod-deadline">Deadline:
|
2024-02-22 23:20:46 +01:00
|
|
|
<?php //the_field('xxp_convo_apply_begin'); ?>
|
|
|
|
<?php the_field('xxp_convo_apply_end'); ?>
|
2024-02-20 23:13:06 +01:00
|
|
|
</h6>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
2024-02-22 23:20:46 +01:00
|
|
|
<?php if( get_field('xxp_convo_apply_text') ): ?>
|
2024-03-14 11:46:00 +01:00
|
|
|
<h6 class="item-xxp_convo_apply_text"><?php the_field('xxp_convo_apply_text'); ?></h6>
|
2024-02-20 23:13:06 +01:00
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<section class="excerpt post-excerpt">
|
2024-03-30 14:29:34 +01:00
|
|
|
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark" class="">
|
|
|
|
<?php echo wp_trim_words(get_the_excerpt(), 16); // https://developer.wordpress.org/reference/functions/wp_trim_words/?>
|
|
|
|
</a>
|
2024-02-20 23:13:06 +01:00
|
|
|
</section>
|
2024-03-14 11:46:00 +01:00
|
|
|
<aside class="convo-sector convo-field">
|
2024-02-22 23:20:46 +01:00
|
|
|
<?php get_template_part( 'template-parts/section', 'list-checkbox', array('iterate_field' => 'xxp_convo_field') ); ?>
|
2024-02-20 23:13:06 +01:00
|
|
|
</aside>
|
|
|
|
|
|
|
|
<nav class="more-link">
|
|
|
|
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark" class="button button-more">
|
|
|
|
Més info
|
|
|
|
<span class="hide"><?php the_title(); ?></span>
|
|
|
|
</a>
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<?php endwhile;//end of the loop ?>
|
|
|
|
<?php wp_reset_postdata(); ?>
|
|
|
|
<?php else : //if no post in query ?>
|
2024-03-12 23:33:12 +01:00
|
|
|
<p class="no-content"> No convos </p>
|
|
|
|
<?php endif; //end WP_Query ?>
|
2024-02-20 23:13:06 +01:00
|
|
|
|
|
|
|
</main>
|
|
|
|
<?php } //closing if is_plugin_active ?>
|
2024-02-29 12:04:10 +01:00
|
|
|
</section>
|