changed loops in archive category and convos, ajut, agenda to properly show today and future content
This commit is contained in:
parent
7a5eb14956
commit
62e087dd80
|
@ -31,22 +31,78 @@ get_header();
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<content class="archive-posts <?php xarxaprod_class_posttype(); ?>">
|
<content class="archive-posts <?php xarxaprod_class_posttype(); ?>">
|
||||||
|
<?php
|
||||||
|
// very wired, need to output
|
||||||
|
// 1. today's events 'compare' => '='
|
||||||
|
// 2. then after today 'compare' => '>'
|
||||||
|
//
|
||||||
|
// if done with '>=' outputs
|
||||||
|
// 1. older dates in asc order
|
||||||
|
// 2. at the end today
|
||||||
|
?>
|
||||||
|
|
||||||
<?php if ( have_posts() ) : ?>
|
<?php
|
||||||
<?php while ( have_posts() ) : the_post();
|
// https://support.advancedcustomfields.com/forums/topic/wp_query-using-meta_query-for-an-acf-checkbox-field/#post-145830
|
||||||
|
// https://www.advancedcustomfields.com/resources/checkbox/#query-posts
|
||||||
|
// https://barn2.com/blog/querying-posts-by-custom-field-acfi/
|
||||||
|
|
||||||
get_template_part( 'template-parts/section', 'eachfund' );
|
$the_query_ajut = new WP_Query(
|
||||||
|
array(
|
||||||
|
'post_type' => 'xarxaprod-ajut',
|
||||||
|
'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
|
||||||
|
)
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
<?php if ( $the_query_ajut->have_posts() ) : ?>
|
||||||
|
<?php while ( $the_query_ajut->have_posts() ) : $the_query_ajut->the_post(); ?>
|
||||||
|
|
||||||
endwhile;
|
<?php get_template_part( 'template-parts/section', 'eachfund' ); ?>
|
||||||
|
|
||||||
the_posts_navigation();
|
<?php endwhile;//end of the loop ?>
|
||||||
|
<?php wp_reset_postdata(); ?>
|
||||||
|
<?php endif; //end query ajut ?>
|
||||||
|
<?php
|
||||||
|
|
||||||
else :
|
$the_query_ajut = new WP_Query(
|
||||||
|
array(
|
||||||
|
'post_type' => 'xarxaprod-ajut',
|
||||||
|
'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
|
||||||
|
)
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
<?php if ( $the_query_ajut->have_posts() ) : ?>
|
||||||
|
<?php while ( $the_query_ajut->have_posts() ) : $the_query_ajut->the_post(); ?>
|
||||||
|
|
||||||
get_template_part( 'template-parts/content', 'none' );
|
<?php get_template_part( 'template-parts/section', 'eachfund' ); ?>
|
||||||
|
|
||||||
|
<?php endwhile;//end of the loop ?>
|
||||||
|
<?php wp_reset_postdata(); ?>
|
||||||
|
<?php endif; //end query ajut ?>
|
||||||
|
|
||||||
endif;
|
|
||||||
?>
|
|
||||||
|
|
||||||
</content>
|
</content>
|
||||||
<section id="filteredfunds" class="xarxaprod-filtered-content xarxaprod-filtered-funds xarxaprod-ajuts-filtrats">
|
<section id="filteredfunds" class="xarxaprod-filtered-content xarxaprod-filtered-funds xarxaprod-ajuts-filtrats">
|
||||||
|
|
|
@ -21,6 +21,7 @@ get_header();
|
||||||
|
|
||||||
<header class="page-header">
|
<header class="page-header">
|
||||||
<h1><?php //single_term_title( ' ' ); ?></h1>
|
<h1><?php //single_term_title( ' ' ); ?></h1>
|
||||||
|
this is achive-xarxaprod-convo.php
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<aside id="convosfilter" class="xarxaprod-filter-convos xarxaprod-filtre-convos">
|
<aside id="convosfilter" class="xarxaprod-filter-convos xarxaprod-filtre-convos">
|
||||||
|
@ -32,16 +33,14 @@ get_header();
|
||||||
<content class="archive-posts <?php xarxaprod_class_posttype(); ?>">
|
<content class="archive-posts <?php xarxaprod_class_posttype(); ?>">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// loop by default in archive.php
|
// very wired, need to output
|
||||||
//if ( have_posts() ) :
|
// 1. today's events 'compare' => '='
|
||||||
// while ( have_posts() ) : the_post();
|
// 2. then after today 'compare' => '>'
|
||||||
// get_template_part( 'template-parts/section', 'eachconvo' );
|
//
|
||||||
// endwhile;
|
// if done with '>=' outputs
|
||||||
// the_posts_navigation();
|
// 1. older dates in asc order
|
||||||
//else :
|
// 2. at the end today
|
||||||
// get_template_part( 'template-parts/content', 'none' );
|
?>
|
||||||
//endif;
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// https://support.advancedcustomfields.com/forums/topic/wp_query-using-meta_query-for-an-acf-checkbox-field/#post-145830
|
// https://support.advancedcustomfields.com/forums/topic/wp_query-using-meta_query-for-an-acf-checkbox-field/#post-145830
|
||||||
|
@ -50,18 +49,49 @@ 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',
|
||||||
'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 from today and later
|
'compare' => '=', //show events from today and later
|
||||||
'type' => 'DATE',
|
'type' => 'DATE',
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
|
'order_by' => 'meta_value', //order by meta value
|
||||||
|
'order' => 'ASC', //order ascendent
|
||||||
|
)
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
<?php if ( $the_query_convo->have_posts() ) : ?>
|
||||||
|
<?php while ( $the_query_convo->have_posts() ) : $the_query_convo->the_post(); ?>
|
||||||
|
|
||||||
|
<?php get_template_part( 'template-parts/section', 'eachconvo' , $the_query_convo); ?>
|
||||||
|
|
||||||
|
<?php endwhile;//end of the loop ?>
|
||||||
|
<?php wp_reset_postdata(); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// https://support.advancedcustomfields.com/forums/topic/wp_query-using-meta_query-for-an-acf-checkbox-field/#post-145830
|
||||||
|
// https://www.advancedcustomfields.com/resources/checkbox/#query-posts
|
||||||
|
// https://barn2.com/blog/querying-posts-by-custom-field-acfi/
|
||||||
|
$the_query_convo = new WP_Query(
|
||||||
|
array(
|
||||||
|
'post_type' => 'xarxaprod-convo',
|
||||||
|
'posts_per_page' => '-1', //show all
|
||||||
|
'meta_key' => 'xxp_convo_apply_end', // order by meta key convo apply end
|
||||||
|
'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',
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'order_by' => 'meta_value', //order by meta value
|
||||||
|
'order' => 'ASC', //order ascendent
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
|
|
79
archive.php
79
archive.php
|
@ -38,29 +38,76 @@ get_header();
|
||||||
<content class="archive-posts <?php xarxaprod_class_posttype(); ?>">
|
<content class="archive-posts <?php xarxaprod_class_posttype(); ?>">
|
||||||
<?php
|
<?php
|
||||||
/* Start the Loop */
|
/* Start the Loop */
|
||||||
while ( have_posts() ) :
|
//while ( have_posts() ) :
|
||||||
the_post();
|
// the_post();
|
||||||
|
|
||||||
/*
|
if( in_category('faq') ) {
|
||||||
* Include the Post-Type-specific template for the content.
|
while ( have_posts() ) :
|
||||||
* If you want to override this in a child theme, then include a file
|
the_post();
|
||||||
* called content-___.php (where ___ is the Post Type name) and that will be used instead.
|
get_template_part( 'template-parts/section', 'each-faq' );
|
||||||
*/
|
endwhile;
|
||||||
//get_template_part( 'template-parts/content', get_post_type() );
|
the_posts_navigation();
|
||||||
|
//end if is_category faq
|
||||||
|
} elseif (in_category( array( 'activitats') ) ) {
|
||||||
|
//get_template_part( 'template-parts/section', 'each-agenda-entry' );
|
||||||
|
|
||||||
get_template_part( 'template-parts/section', 'each-agenda-entry' );
|
$the_query_archive_activitats = new WP_Query(
|
||||||
|
array(
|
||||||
|
'post_type' => 'post',
|
||||||
|
'posts_per_page' => '-1', //show all => -1
|
||||||
|
'tax_query' => array(
|
||||||
|
array(
|
||||||
|
'taxonomy' => 'category',
|
||||||
|
'field' => 'slug',
|
||||||
|
'terms' => 'activitats'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'meta_query' => array(
|
||||||
|
array( //filter results show only older than today
|
||||||
|
'key' => 'xxp_agenda_date_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',
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'order_by' => 'meta_value', //order by meta value
|
||||||
|
'order' => 'ASC', //order ascendent
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if ( $the_query_archive_activitats->have_posts() ) :
|
||||||
|
while ( $the_query_archive_activitats->have_posts() ) : $the_query_archive_activitats->the_post();
|
||||||
|
|
||||||
endwhile;
|
get_template_part( 'template-parts/section', 'each-agenda-entry' );
|
||||||
|
|
||||||
the_posts_navigation();
|
endwhile;//end of the loop
|
||||||
echo '</content>';
|
// pagination will not work for custom_query, why and fix: https://wordpress.stackexchange.com/a/120408
|
||||||
|
// the_posts_navigation();
|
||||||
|
endif; //end if the_query_archive_activitats
|
||||||
|
|
||||||
else :
|
wp_reset_postdata(); //reset custom query
|
||||||
get_template_part( 'template-parts/content', 'none' );
|
|
||||||
|
|
||||||
endif;
|
//end in_category agenda activitats
|
||||||
|
}else{
|
||||||
|
//the rest of archives
|
||||||
|
while ( have_posts() ) :
|
||||||
|
the_post();
|
||||||
|
/*
|
||||||
|
* Include the Post-Type-specific template for the content.
|
||||||
|
* If you want to override this in a child theme, then include a file
|
||||||
|
* called content-___.php (where ___ is the Post Type name) and that will be used instead.
|
||||||
|
*/
|
||||||
|
//get_template_part( 'template-parts/content', get_post_type() );
|
||||||
|
get_template_part( 'template-parts/section', 'each-entry' );
|
||||||
|
endwhile;
|
||||||
|
the_posts_navigation();
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
else : //no if have_posts
|
||||||
|
|
||||||
|
get_template_part( 'template-parts/content', 'none' ); ?>
|
||||||
|
|
||||||
|
</content>
|
||||||
|
<?php endif; //end if have_posts?>
|
||||||
|
|
||||||
</main><!-- #main -->
|
</main><!-- #main -->
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ get_header();
|
||||||
'terms' => 'activitats'
|
'terms' => 'activitats'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
//'order_by' => 'meta_value', //order by meta value
|
'order_by' => 'meta_value', //order by meta value
|
||||||
//'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(
|
||||||
|
|
|
@ -18,7 +18,8 @@ get_header();
|
||||||
|
|
||||||
<?php if ( have_posts() ) : ?>
|
<?php if ( have_posts() ) : ?>
|
||||||
|
|
||||||
<header class="page-header">
|
<header class="page-header">
|
||||||
|
this is convo-search.php
|
||||||
</header><!-- .page-header -->
|
</header><!-- .page-header -->
|
||||||
<?php
|
<?php
|
||||||
while ( have_posts() ) :
|
while ( have_posts() ) :
|
||||||
|
@ -61,7 +62,7 @@ get_header();
|
||||||
'type' => 'DATE',
|
'type' => 'DATE',
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
//https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
|
//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
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Template part for displaying posts from category "agenda"
|
||||||
|
*
|
||||||
|
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
|
||||||
|
*
|
||||||
|
* @package Xarxaprod_theme
|
||||||
|
* @used by template-parts/content-post.php
|
||||||
|
* @shown in : archive category
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
?>
|
||||||
|
<article id="post-<?php the_ID(); ?>" <?php post_class('xarxaprod-card-each'); ?> >
|
||||||
|
<h3 class="entry-title">
|
||||||
|
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark">
|
||||||
|
<?php the_title(); ?>
|
||||||
|
</a>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<?php if ( get_the_excerpt() ){ ?>
|
||||||
|
<section class="excerpt post-excerpt">
|
||||||
|
<?php //the_excerpt() ?>
|
||||||
|
<?php echo wp_trim_words(get_the_excerpt(), 22); // https://developer.wordpress.org/reference/functions/wp_trim_words/?>
|
||||||
|
</section>
|
||||||
|
<?php ; }?>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
</article>
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Template part for displaying posts from category "agenda"
|
||||||
|
*
|
||||||
|
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
|
||||||
|
*
|
||||||
|
* @package Xarxaprod_theme
|
||||||
|
* @used by template-parts/content-post.php
|
||||||
|
* @shown in : archive category
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
?>
|
||||||
|
<article id="post-<?php the_ID(); ?>" <?php post_class('xarxaprod-card-each'); ?> >
|
||||||
|
<h3 class="entry-title">
|
||||||
|
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark">
|
||||||
|
<?php the_title(); ?>
|
||||||
|
</a>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<aside class="xarxaprod-faq-info">
|
||||||
|
</aside>
|
||||||
|
<?php if ( get_the_excerpt() ){ ?>
|
||||||
|
<section class="excerpt post-excerpt">
|
||||||
|
<?php //the_excerpt() ?>
|
||||||
|
<?php echo wp_trim_words(get_the_excerpt(), 22); // https://developer.wordpress.org/reference/functions/wp_trim_words/?>
|
||||||
|
</section>
|
||||||
|
<?php ; }?>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
</article>
|
Loading…
Reference in New Issue