xarxaprod-wp-theme/template-parts/content-xarxaprod-convo.php

171 lines
6.4 KiB
PHP

<?php
/**
* Template part for displaying posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Xarxaprod_theme
*/
?>
<!-- template-parts content-xarxaprod-convo-php -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header><!-- .entry-header -->
<aside cass="xarxaprod-espai-image">
<?php
if( get_field('xxp_convo_espai_associat') ):
// read here howto
// https://www.advancedcustomfields.com/resources/relationship/#display-list-of-posts-with-setuppostdata
$espai_associat_posts = get_field('xxp_convo_espai_associat');
if( $espai_associat_posts ):
foreach( $espai_associat_posts as $post ):
// Setup this post for WP functions (variable must be named $post).
setup_postdata($post); ?>
<?php
// search and output images
// check if has post_thumbnail
if ( has_post_thumbnail() ){
xarxaprod_post_thumbnail('full');
} else { ?>
<?php if( have_rows('xxp_associat_gallery_images') ){ ?>
<section class="xarxaprod-associat-gallery-images">
<ul class="xarxaprod-associat-slides">
<?php while( have_rows('xxp_associat_gallery_images') ): the_row(); ?>
<?php $image=get_sub_field('xxp_associat_image'); ?>
<li id="<?php echo acf_esc_html( $image['filename'] );?>" class="xarxaprod-associat-image">
<?php //print_r( $image ); //echo the whole array ?>
<?php //print_r( $image['ID'] ); // echo one fiels of the array?>
<?php echo wp_get_attachment_image( $image['ID'], 'full' ); ?>
<p class="caption"><?php //echo acf_esc_html( $image['caption'] );?></p>
</li>
<?php endwhile; //end while has rows ?>
</ul>
</section>
<?php }; //end if xxp_associat_gallery_images ?>
<?php };//end has_post_thumbnail ?>
<?php endforeach;
// Reset the global post object so that the rest of the page works correctly.
wp_reset_postdata();
endif;
endif;
?>
</aside>
<section class="xarxaprod-convo-info-fields">
<ul>
<?php if( get_field('xxp_convo_espai_associat') ):
// read here howto
// https://www.advancedcustomfields.com/resources/relationship/#display-list-of-posts-with-setuppostdata
$espai_associat_posts = get_field('xxp_convo_espai_associat');
if( $espai_associat_posts ):
foreach( $espai_associat_posts as $post ):
// Setup this post for WP functions (variable must be named $post).
setup_postdata($post); ?>
<li class="xarxaprod-convo-espai-associat">
<dt>Espai Associat</dt>
<dd><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></dd>
</li>
<li class="xarxaprod-convo-associat-address">
<dt>Lloc</dt>
<dd><a href="<?php the_permalink(); ?>"><?php echo wp_kses_post( get_field('xxp_associat_address') ); ?></a></dd>
</li>
<?php endforeach;
// Reset the global post object so that the rest of the page works correctly.
wp_reset_postdata();
else: ?>
<?php if( get_field('xxp_convoer_name') ): ?>
<li class="xarxaprod-convo-field">
<dt>Centre</dt>
<dd class="xarxaprod-convoer-name"><?php the_field('xxp_convoer_name'); ?></dd>
</li>
<?php endif; ?>
<?php endif; //end if has posts espai associat ?>
<?php endif; //end if has relation with other espai associat ?>
<li class="xarxaprod-convo-field">
<dt>Disciplines</dt>
<dd><?php get_template_part( 'template-parts/section', 'list-checkbox', array('iterate_field' => 'xxp_convo_field') ); ?></dd>
</li>
<li class="xarxaprod-convo-info-date">
<dt>Termini</dt>
<?php if( get_field('xxp_convo_apply_begin') || get_field('xxp_convo_apply_end') ): ?>
<dd class="xarxaprod-label item-xxp_convo_dates">
<?php if( get_field('xxp_convo_apply_begin') ): ?>
<span class="item-xxp_convo_apply_begin">del <?php the_field('xxp_convo_apply_begin'); ?> </span>
<?php endif; ?>
<?php if( get_field('xxp_convo_apply_end') && !get_field('xxp_convo_apply_begin') ){ echo 'fins'; } ?>
<?php if( get_field('xxp_convo_apply_end') ): ?>
<span class="item-xxp_convo_apply_end">al <?php the_field('xxp_convo_apply_end'); ?> </span>
<?php endif; ?>
<?php if( get_field('xxp_convo_apply_text') ): ?>
<span class="item-xxp_convo_apply_text"><?php the_field('xxp_convo_apply_text'); ?></span>
<?php endif; ?>
</dd>
<?php endif; ?>
</li>
<li class="xarxaprod-convo-info-date">
<dt>Periode</dt>
<?php if( get_field('xxp_convo_date_begin') || get_field('xxp_convo_date_end') ): ?>
<dd class="xarxaprod-label item-xxp_convo_dates">
<?php if( get_field('xxp_convo_date_begin') ): ?>
<span class="item-xxp_convo_date_begin">del <?php the_field('xxp_convo_date_begin'); ?> </span>
<?php endif;?>
<?php if( get_field('xxp_convo_date_end') && !get_field('xxp_convo_date_begin') ){ echo 'fins'; } ?>
<?php if( get_field('xxp_convo_date_end') ): ?>
<span class="item-xxp_convo_date_end">al <?php the_field('xxp_convo_date_end'); ?> </span>
<?php endif;?>
</dd>
<?php endif; ?>
</li>
</ul>
</section>
<main class="entry-content">
<?php
the_content(
sprintf(
wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'xarxaprod' ),
array(
'span' => array(
'class' => array(),
),
)
),
wp_kses_post( get_the_title() )
)
);
wp_link_pages(
array(
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'xarxaprod' ),
'after' => '</div>',
)
);
?>
</main><!-- .entry-content -->
<section class="">
</section>
<footer class="entry-footer">
<h6 class="xarxaprod-more-convos-header big"> Altres convòcatories</h6>
<?php get_template_part( 'template-parts/section', 'last-convos' ); ?>
<?php xarxaprod_entry_footer(); ?>
</footer><!-- .entry-footer -->
</article><!-- #post-<?php the_ID(); ?> -->