In a template file like this:
<?php
/**
* Template Name: Collezioni
*/
get_header();
// recupero la variabile per mobile detect
global $detect;
// recupero la variabile per la lingua
global $currentlang;
// Parametri url
$display = $_GET[‘display’];
?>
<script>
$(document).ready(function() {
$(“.page-item-<?php echo $display; ?>”).addClass(‘current_page_item’);
});
</script>
<div class=”block_100″>
<div class=”wrapper”>
<div class=”first_page_padder”>
<ul id=”prod_grid”>
<?php
$module_counter = 0;
$vertical_image_array = array ( ‘1’, ‘5’, ‘7’, ’11’, ’13’, ’17’, ’19’, ’23’, ’25’, ’29’, ’31’ );
$args_events = array(
‘post_type’ => array( ‘collezione’, ‘post’ ),
‘lang’ => $currentlang,
‘manichino-type’ => $display,
‘orderby’ => ‘menu_order’,
‘order’ => ‘DESC’,
‘posts_per_page’ => -1
);
$my_appuntamenti = get_posts( $args_events );
foreach ( $my_appuntamenti as $post ) : setup_postdata ($post );
$module_counter++;
$riassunto = get_field(‘riassunto’);
// IMMAGINE DI COPERTINA – scelgo se verticale o orizzontale
if (in_array($module_counter, $vertical_image_array)) {
// IMMAGINE DI COPERTINA VERTICALE
$immagine_copertina = get_field(‘cover_img_vertical’);
// smartphone
if( $detect->isMobile() && !$detect->isTablet() ) {
$immagine_copertinaURL = $immagine_copertina[‘sizes’][‘full_smart’];
}
// tablet
elseif( $detect->isTablet() ) {
$immagine_copertinaURL = $immagine_copertina[‘sizes’][‘full_tab’];
}
// desktop
else {
$immagine_copertinaURL = $immagine_copertina[‘sizes’][‘full_desk’];
}
}
else {
// IMMAGINE DI COPERTINA ORIZZONTALE
$immagine_copertina = get_field(‘cover_img’);
// smartphone
if( $detect->isMobile() && !$detect->isTablet() ) {
$immagine_copertinaURL = $immagine_copertina[‘sizes’][‘full_smart’];
}
// tablet
elseif( $detect->isTablet() ) {
$immagine_copertinaURL = $immagine_copertina[‘sizes’][‘full_tab’];
}
// desktop
else {
$immagine_copertinaURL = $immagine_copertina[‘sizes’][‘full_desk’];
}
}
if ( $file_video_webm != ” ) {
$immagine_copertinaURL = ”;
}
if( !$detect->isMobile() ) {
$icona_collezione = get_field(‘icona_collezione’);
$icona_collezioneURL = $icona_collezione[‘sizes’][‘product_icon’];
$descrizione_aggiuntiva = get_field(‘descrizione_aggiuntiva’);
}
?>
<li class=”fader”>
<div class=”lazy lazyPreload block_bg” data-background=”<?php echo $immagine_copertinaURL; ?>” style=”background-image: url(‘<?php bloginfo(‘stylesheet_directory’); ?>/images/icons/block_preload.gif’);”></div><!– .block_bg –>
” class=”absl” title=”<?php the_title(); ?>”>
<div class=”text_place txt-bianco aligncenter bg-nero-alpha-80″>
<div class=”text_placer”>
<?php if ( $icona_collezione != ” ) : ?>
<img src=”<?php echo $icona_collezioneURL; ?>” class=”collection_icon” />
<?php else : ?>
<h3><?php the_title(); ?></h3>
<?php endif; ?>
<h3><?php echo $descrizione_aggiuntiva; ?></h3>
<div class=”cta txt-grigio-1″>
<?php $collezione = ${‘collezione_’ . $currentlang}; echo $collezione; ?>
</div><!– .cta –>
</div><!– .text_placer –>
</div><!– .text_place –>
<?php
endforeach;
wp_reset_postdata();
?>
<div class=”clearer”></div>
<?php get_template_part(‘/page-templates/theme-newsletter’); ?>
</div><!– .first_page_padder –>
</div><!– .wrapper –>
</div><!– .block_100 –>
<?php get_footer(); ?>