codice per la griglia degli articoli in evidenza

This commit is contained in:
ulaulaman 2018-06-22 10:57:58 +02:00 committed by GitHub
parent 44c365820d
commit 5ce61b8adf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 54 additions and 0 deletions

54
incl/evidenza.php Normal file
View File

@ -0,0 +1,54 @@
#griglia per la home page
add_shortcode ( 'grigliaevidenza', 'grigliaevidenza');
function grigliaevidenza () {
$qtax = array(
array (
'taxonomy' => 'collezioni',
'field' => 'slug',
'terms' => 'evidenza',
)
);
$q0 = new WP_Query( array( 'posts_per_page' => 1,
'tax_query' => $qtax,
));
$q = new WP_Query( array( 'posts_per_page' => 4, 'offset' => 1,
'tax_query' => $qtax,
));
$gridup = '<div class="evidenza">';
if ( $q0->have_posts() ) {
while ( $q0->have_posts() ) {
$q0->the_post();
$thumb = get_the_post_thumbnail($post->ID, 'full');
$gridup = $gridup.'<div class="up"><span class="grid-border">'.$thumb.'<h4 class="titoloevidenza"><a href="'.get_the_permalink().'">'.get_the_title().'</a></h4></span></div>';
}
$gridup = $gridup.'</div>';
/* ripristino */
wp_reset_postdata();
} else {
$gridup = '<p><strong>Nessun articolo trovato</strong></p>';
}
$grid = $gridup.'<div class="evidenza">';
if ( $q->have_posts() ) {
while ( $q->have_posts() ) {
$q->the_post();
$thumb = get_the_post_thumbnail($post->ID, 'thumbnail');
$grid = $grid.'<div><span class="grid-border">'.$thumb.'<h4 class="titoloevidenza"><a href="'.get_the_permalink().'">'.get_the_title().'</a></h4></span></div>';
}
$grid = $grid.'</div>';
/* ripristino */
wp_reset_postdata();
} else {
$grid = '<p><strong>Nessun articolo trovato</strong></p>';
}
return $grid;
}