From d205cf49d5626c487014b99d7a6cce40c9b1d27b Mon Sep 17 00:00:00 2001 From: jorge-vitrubio Date: Wed, 13 Mar 2024 19:41:07 +0100 Subject: [PATCH] odered convos by due date and hide once finished. create automatic archive --- page-templates/convos-archive.php | 82 ++++++++++++++++++++++++++ page-templates/convos-search.php | 15 ++++- template-parts/section-last-convos.php | 37 +++++++++--- 3 files changed, 124 insertions(+), 10 deletions(-) create mode 100644 page-templates/convos-archive.php diff --git a/page-templates/convos-archive.php b/page-templates/convos-archive.php new file mode 100644 index 0000000..554456c --- /dev/null +++ b/page-templates/convos-archive.php @@ -0,0 +1,82 @@ + + +
+ + + + + +
+ + + + '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 + 'meta_query' => array( + array( //filter results show only older than today + '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 before today + 'type' => 'DATE', + ) + ) + ) + ); + ?> + have_posts() ) : ?> + + have_posts() ) : $the_query_archive_convo->the_post(); ?> + + + + + + + + +
+
+ + 'xarxaprod-convo', - 'posts_per_page' => '-1' + '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 + 'meta_query' => array( + array( //filter results show only older than today + '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 from today and later + 'type' => 'DATE', + ) + ) ) ); ?> diff --git a/template-parts/section-last-convos.php b/template-parts/section-last-convos.php index 6bd069c..d511090 100644 --- a/template-parts/section-last-convos.php +++ b/template-parts/section-last-convos.php @@ -19,7 +19,7 @@ ?>
'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( + 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 '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" @@ -43,14 +52,26 @@
array( 'xarxaprod-convo' ), - 'posts_per_page' => '3' - ) ); + $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', + ), + ) + ) + ); ?>