From be6f552f1f83a9e7bf76517a877603e272b91260 Mon Sep 17 00:00:00 2001
From: ulaulaman
Date: Fri, 23 Mar 2018 23:33:38 +0100
Subject: [PATCH] Aggiunto file per la creazione dei loop per gli speciali con
il css di personalizzazione
---
incl/speciale.css | 4 ++
incl/speciali.php | 128 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 132 insertions(+)
create mode 100644 incl/speciale.css
create mode 100644 incl/speciali.php
diff --git a/incl/speciale.css b/incl/speciale.css
new file mode 100644
index 0000000..9aecd1e
--- /dev/null
+++ b/incl/speciale.css
@@ -0,0 +1,4 @@
+h4.titolospeciale {
+ background: #ecb252;
+ text-align: left;
+}
diff --git a/incl/speciali.php b/incl/speciali.php
new file mode 100644
index 0000000..6c68ace
--- /dev/null
+++ b/incl/speciali.php
@@ -0,0 +1,128 @@
+ _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 = '';
+
+ if ( $q->have_posts() ) {
+ while ( $q->have_posts() ) {
+ $q->the_post();
+ $titolo = get_the_title();
+
+ $grid .= '';
+ }
+ $grid = $header.$grid.'
';
+ /* ripristino */
+ wp_reset_postdata();
+ }
+
+ $container = ''.$grid.'
';
+
+ 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 = '';
+
+ 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 = '
'.$titolo.'
';
+ $content .= $header.'di '.$autori.'
'.$tassonomia.'
'.$estratto.'
(continua)
';
+ }
+ $content = $content.'';
+ /* ripristino */
+ wp_reset_postdata();
+ }
+
+ return $content;
+
+}
+
+add_shortcode( 'grigliaspeciali', 'grigliaspeciali' );