ordered funds, ajuts, convos, agenda by date as in meta field

This commit is contained in:
jorge 2024-04-15 12:13:51 +02:00
parent 8da89e0ff4
commit a1c402ebe2
5 changed files with 45 additions and 13 deletions

View File

@ -48,7 +48,7 @@ get_header();
<content class="archive-posts <?php //xarxaprod_class_posttype(); ?>"> <content class="archive-posts <?php //xarxaprod_class_posttype(); ?>">
<?php <?php
$the_query_archive_agenda = new WP_Query( $the_query_archive_agenda = new WP_Query(
array( array(
'post_type' => 'post', 'post_type' => 'post',
'posts_per_page' => '40', //show all => -1 'posts_per_page' => '40', //show all => -1
@ -67,6 +67,7 @@ get_header();
'type' => 'DATE', 'type' => 'DATE',
) )
), ),
//https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
'orderby' => 'meta_value', //order by meta value 'orderby' => 'meta_value', //order by meta value
'order' => 'ASC', //order ascendent 'order' => 'ASC', //order ascendent
) )

View File

@ -54,7 +54,19 @@ get_header();
$the_query_ajut = new WP_Query( $the_query_ajut = new WP_Query(
array( array(
'post_type' => 'xarxaprod-ajut', 'post_type' => 'xarxaprod-ajut',
'posts_per_page' => '-1' 'posts_per_page' => '-1',
'meta_key' => 'xxp_fund_apply_end', // order by meta key convo apply end
'meta_query' => array(
array( //filter results show only older than today
'key' => 'xxp_fund_apply_end',
'value' => date("Y-m-d"), // consider using date_i18n() https://developer.wordpress.org/reference/functions/date_i18n/
'compare' => '>=', //show events from today and later
'type' => 'DATE',
)
),
//https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
'orderby' => 'meta_value', //order by meta value
'order' => 'ASC', //order ascendent
) )
); );
?> ?>

View File

@ -51,10 +51,8 @@ get_header();
$the_query_convo = new WP_Query( $the_query_convo = new WP_Query(
array( array(
'post_type' => 'xarxaprod-convo', 'post_type' => 'xarxaprod-convo',
'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
'posts_per_page' => '-1', //show all 'posts_per_page' => '-1', //show all
'meta_key' => 'xxp_convo_apply_end', // order by meta key convo apply end
'meta_query' => array( 'meta_query' => array(
array( //filter results show only older than today array( //filter results show only older than today
'key' => 'xxp_convo_apply_end', 'key' => 'xxp_convo_apply_end',
@ -62,7 +60,10 @@ get_header();
'compare' => '>=', //show events from today and later 'compare' => '>=', //show events from today and later
'type' => 'DATE', 'type' => 'DATE',
) )
) ),
//https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
'orderby' => 'meta_value', //order by meta value
'order' => 'ASC', //order ascendent
) )
); );
?> ?>

View File

@ -32,8 +32,20 @@
'field' => 'slug', 'field' => 'slug',
'terms' => 'activitats','actividades','agenda','agenda-es' '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 if ( $agenda_query->have_posts() ) : ?>
<?php while ( $agenda_query->have_posts() ) : $agenda_query->the_post(); ?> <?php while ( $agenda_query->have_posts() ) : $agenda_query->the_post(); ?>

View File

@ -33,17 +33,20 @@
'meta_key' => 'xxp_convo_apply_end', // order by meta key convo apply end 'meta_key' => 'xxp_convo_apply_end', // order by meta key convo apply end
'order' => 'ASC', //order ascendent 'order' => 'ASC', //order ascendent
'meta_query' => array( 'meta_query' => array(
array( //filter results show today and later 'query_convo_apply_end' => array( //filter results show today and later
'key' => 'xxp_convo_apply_end', 'key' => 'xxp_convo_apply_end',
'value' => date("Y-m-d"), // consider using date_i18n() https://developer.wordpress.org/reference/functions/date_i18n/ 'value' => date("Y-m-d"), // consider using date_i18n() https://developer.wordpress.org/reference/functions/date_i18n/
'compare' => '>=', //show events today and later 'compare' => '>=', //show events today and later
'type' => 'DATE', 'type' => 'DATE',
), ),
array( //filter convos with relation to espai associat 'query_convo_espai_associat' => array( //filter convos with relation to espai associat
'key' => 'xxp_convo_espai_associat', // name of the custom field 'key' => 'xxp_convo_espai_associat', // name of the custom field
'value' => '"' . get_the_ID() . '"', // in ACF select Return format "Post ID" '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" 'compare'=> 'LIKE', // matches exaclty "123", not just 123. This prevents a match for "1234"
) ),
'orderby' => array (
'query_convo_apply_end' => 'ASC',
),
) )
) )
); );
@ -69,7 +72,10 @@
'compare' => '>=', //show events today and later 'compare' => '>=', //show events today and later
'type' => 'DATE', 'type' => 'DATE',
), ),
) ),
//https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
'orderby' => 'meta_value', //order by meta value
'order' => 'ASC', //order ascendent
) )
); );
?> ?>