mirror of
https://github.com/ulaulaman/eduinaf.git
synced 2025-03-03 11:57:44 +01:00
Aggiunto file per la creazione dei loop per gli speciali con il css di personalizzazione
This commit is contained in:
parent
cf48695b63
commit
be6f552f1f
4
incl/speciale.css
Normal file
4
incl/speciale.css
Normal file
@ -0,0 +1,4 @@
|
||||
h4.titolospeciale {
|
||||
background: #ecb252;
|
||||
text-align: left;
|
||||
}
|
128
incl/speciali.php
Normal file
128
incl/speciali.php
Normal file
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
# tassonomia per gli speciali
|
||||
# guida https://code.tutsplus.com/tutorials/adding-post-series-functionality-to-wordpress-with-taxonomies--wp-25414
|
||||
|
||||
function speciali_tax() {
|
||||
$labels = array(
|
||||
'name' => _x('Speciali', 'taxonomy general name'),
|
||||
'singular_name' => _x('Speciale', 'taxonomy singular name'),
|
||||
'all_items' => __('Tutti gli speciali'),
|
||||
'edit_item' => __('Modifica speciale'),
|
||||
'update_item' => __('Aggiorna speciale'),
|
||||
'add_new_item' => __('Aggiungi un nuovo speciale'),
|
||||
'new_item_name' => __('Nuovo speciale'),
|
||||
'menu_name' => __('Speciali'),
|
||||
);
|
||||
|
||||
register_taxonomy(
|
||||
'speciali',
|
||||
array('post'), /* per estendere array('post','page','custom-post-type') */
|
||||
array(
|
||||
'hierarchical' => true,
|
||||
'labels' => $labels,
|
||||
'show_ui' => true,
|
||||
'query_var' => true,
|
||||
'rewrite' => array('slug' => 'speciali'),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
add_action('init', 'speciali_tax', 0);
|
||||
|
||||
# shortcode per mostrare l'elenco degli articoli di uno speciale
|
||||
|
||||
function specialieduinaf($atts) {
|
||||
|
||||
global $post;
|
||||
|
||||
extract(
|
||||
shortcode_atts(
|
||||
array(
|
||||
'speciale' => 'null',
|
||||
'titolo' => 'null',
|
||||
'linkpage' => 'null',
|
||||
),
|
||||
$atts
|
||||
)
|
||||
);
|
||||
|
||||
$q = new WP_Query( array( 'speciali' => $speciale, 'posts_per_page'=>-1 ) );
|
||||
$nnome = 'null';
|
||||
if ( $titolo <> 'null' ) {
|
||||
$nnome = $titolo;
|
||||
if ( $linkpage <> 'null' ) {
|
||||
$nnome = '<a href="'.$linkpage.'>'.$titolo.'</a>';
|
||||
}
|
||||
} else {
|
||||
$nnome = $speciale;
|
||||
}
|
||||
|
||||
$header = '<div style="float: right; padding: 5px; width: 25%;" class="divTable paleBlueRows"><div class="divTableHeading"><div class="divTableRow"><div class="divTableHead"><strong>Speciale '.$nnome.'</strong></div></div></div>';
|
||||
|
||||
if ( $q->have_posts() ) {
|
||||
while ( $q->have_posts() ) {
|
||||
$q->the_post();
|
||||
$titolo = get_the_title();
|
||||
|
||||
$grid .= '<div class="divTableBody"><div class="divTableRow"><div class="divTableCell"><a href="'.get_the_permalink().'">'.$titolo.'</a></div>';
|
||||
}
|
||||
$grid = $header.$grid.'</div></div>';
|
||||
/* ripristino */
|
||||
wp_reset_postdata();
|
||||
}
|
||||
|
||||
$container = '<p><div>'.$grid.'</div></p>';
|
||||
|
||||
return $container;
|
||||
|
||||
}
|
||||
|
||||
add_shortcode( 'specialieduinaf', 'specialieduinaf' );
|
||||
|
||||
# shortcode per la creazione della griglia per la pagina degli speciali
|
||||
|
||||
function grigliaspeciali($atts) {
|
||||
|
||||
global $post;
|
||||
|
||||
extract(
|
||||
shortcode_atts(
|
||||
array(
|
||||
'speciale' => 'null',
|
||||
),
|
||||
$atts
|
||||
)
|
||||
);
|
||||
|
||||
$q = new WP_Query( array( 'speciali' => $speciale, 'posts_per_page'=>-1 ) );
|
||||
$content = '<p>';
|
||||
|
||||
if ( $q->have_posts() ) {
|
||||
while ( $q->have_posts() ) {
|
||||
$q->the_post();
|
||||
$titolo = get_the_title();
|
||||
#$autori = coauthors_posts_links(", ", " e ", null, null, false); # funziona se installato co-authors plus
|
||||
#$autori = coauthors_posts_links(", ", " e ", null, null, false);
|
||||
if ( function_exists( 'get_coauthors' ) ) {
|
||||
$autori = coauthors_posts_links(", ", " e ", null, null, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
$autori = the_author();
|
||||
}
|
||||
$estratto = get_the_excerpt();
|
||||
$tassonomia = get_the_category_list();
|
||||
|
||||
$header = '<h4 style="color: #ecb252;">'.$titolo.'</h4><hr/>';
|
||||
$content .= $header.'<p><em>di <strong>'.$autori.'</strong><br/>'.$tassonomia.'</em><br/>'.$estratto.'<br/>(<a href="'.get_the_permalink().'" style="color: #1d71b8;">continua</a>)</p>';
|
||||
}
|
||||
$content = $content.'</p>';
|
||||
/* ripristino */
|
||||
wp_reset_postdata();
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
||||
}
|
||||
|
||||
add_shortcode( 'grigliaspeciali', 'grigliaspeciali' );
|
Loading…
x
Reference in New Issue
Block a user