show in espais associat the convos that belong to them
This commit is contained in:
parent
b612a464f1
commit
bebeb0afff
|
@ -90,16 +90,7 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="xarxaprod-associat-convos">
|
<section class="xarxaprod-associat-convos">
|
||||||
|
|
||||||
<?php
|
|
||||||
// https://www.advancedcustomfields.com/resources/bidirectional-relationships/
|
|
||||||
// https://www.advancedcustomfields.com/resources/relationship/
|
|
||||||
;?>
|
|
||||||
<?php get_template_part( 'template-parts/section', 'last-convos' ); ?>
|
<?php get_template_part( 'template-parts/section', 'last-convos' ); ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="xarxaprod-associat-location">
|
<section class="xarxaprod-associat-location">
|
||||||
|
|
|
@ -18,47 +18,32 @@
|
||||||
//plugin is activated do
|
//plugin is activated do
|
||||||
?>
|
?>
|
||||||
<header>
|
<header>
|
||||||
<?php if ( get_post_type( ) == 'xarxaprod-associat' ){ ?>
|
<?php //begin any query
|
||||||
<?php $slug_espai_associat =get_post_field( 'post_name', get_post() ) ; ?>
|
// begin populate WP_Query with custom post type xarxaprod-associat
|
||||||
<?php
|
if ( get_post_type( ) == 'xarxaprod-associat' ){
|
||||||
if( get_field('xxp_convo_espai_associat') ):
|
$slug_espai_associat =get_post_field( 'post_name', get_post() ) ;
|
||||||
$espai_associat_posts = get_field('xxp_convo_espai_associat');
|
// https://developer.wordpress.org/reference/functions/get_posts/
|
||||||
if( $espai_associat_posts ):
|
// query ACF relationsihp
|
||||||
foreach( $espai_associat_posts as $post ):
|
// https://wordpress.stackexchange.com/a/213375
|
||||||
setup_postdata($post);
|
$convos_query = new WP_Query(
|
||||||
//do somethin
|
array(
|
||||||
the_title( '<h3> convos de'.'</h3>');
|
'post_type' => 'xarxaprod-convo',
|
||||||
endforeach;
|
'posts_per_page' => '3',
|
||||||
wp_reset_postdata();
|
'meta_query' => array(
|
||||||
endif;
|
array(
|
||||||
endif;
|
'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"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
?>
|
?>
|
||||||
<h3> <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></h3>
|
<h3> <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></h3>
|
||||||
</header>
|
</header>
|
||||||
<main class="xarxaprod-last-convos xarxaprod-ultimes-convocatories">
|
<main class="xarxaprod-last-convos xarxaprod-ultimes-convocatories">
|
||||||
<?php
|
<?php } //end populate WP_Query custom post type xarxaprod-associat
|
||||||
// https://developer.wordpress.org/reference/functions/get_posts/
|
else { // begin populate WP_Query with others
|
||||||
// https://www.advancedcustomfields.com/resources/true-false/
|
|
||||||
$convos_query = new WP_Query(
|
|
||||||
array(
|
|
||||||
'post_type' => array( 'xarxaprod-convo' ),
|
|
||||||
'posts_per_page' => '3',
|
|
||||||
//'meta_key' => 'xxp_convo_center',
|
|
||||||
'meta_key' => 'xxp_convo_espai_associat',
|
|
||||||
'meta_value' => $slug_espai_associat,
|
|
||||||
//'meta_query' => array (
|
|
||||||
// 'key' => 'xxp_convo_center',
|
|
||||||
// 'value' => $slug,
|
|
||||||
// 'compare' => '=',
|
|
||||||
//)
|
|
||||||
) );
|
|
||||||
?>
|
|
||||||
<?php } else { ?>
|
|
||||||
<h2> <a href="<?php echo site_url() . '/convocatories' ;?>"><?php echo esc_html__('Últimes convocatòries', 'xarxaprod'); ?></a></h2>
|
|
||||||
</header>
|
|
||||||
<main class="xarxaprod-last-convos xarxaprod-ultimes-convocatories">
|
|
||||||
|
|
||||||
<?php
|
|
||||||
// https://developer.wordpress.org/reference/functions/get_posts/
|
// https://developer.wordpress.org/reference/functions/get_posts/
|
||||||
// https://www.advancedcustomfields.com/resources/true-false/
|
// https://www.advancedcustomfields.com/resources/true-false/
|
||||||
$convos_query = new WP_Query(
|
$convos_query = new WP_Query(
|
||||||
|
@ -67,11 +52,14 @@
|
||||||
'posts_per_page' => '3'
|
'posts_per_page' => '3'
|
||||||
) );
|
) );
|
||||||
?>
|
?>
|
||||||
<?php };?>
|
<h2> <a href="<?php echo site_url() . '/convocatories' ;?>"><?php echo esc_html__('Últimes convocatòries', 'xarxaprod'); ?></a></h2>
|
||||||
|
</header>
|
||||||
|
<main class="xarxaprod-last-convos xarxaprod-ultimes-convocatories">
|
||||||
|
<?php }; //end populate WP_Query with others ?>
|
||||||
|
<?php //begin loop WP_Query ?>
|
||||||
<?php if ( $convos_query->have_posts() ) : ?>
|
<?php if ( $convos_query->have_posts() ) : ?>
|
||||||
<?php while ( $convos_query->have_posts() ) : $convos_query->the_post(); ?>
|
<?php while ( $convos_query->have_posts() ) : $convos_query->the_post(); ?>
|
||||||
|
|
||||||
|
|
||||||
<div class="xarxaprod-card-each xarxaprod-convo-info-field">
|
<div class="xarxaprod-card-each xarxaprod-convo-info-field">
|
||||||
<header class="entry-header">
|
<header class="entry-header">
|
||||||
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark" class="">
|
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark" class="">
|
||||||
|
@ -110,10 +98,8 @@
|
||||||
<?php endwhile;//end of the loop ?>
|
<?php endwhile;//end of the loop ?>
|
||||||
<?php wp_reset_postdata(); ?>
|
<?php wp_reset_postdata(); ?>
|
||||||
<?php else : //if no post in query ?>
|
<?php else : //if no post in query ?>
|
||||||
<p class="no-content"></p>
|
<p class="no-content"> No convos </p>
|
||||||
<?php endif; //end query ?>
|
<?php endif; //end WP_Query ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
<?php } //closing if is_plugin_active ?>
|
<?php } //closing if is_plugin_active ?>
|
||||||
|
|
Loading…
Reference in New Issue