mirror of
https://github.com/ulaulaman/eduinafbackupcode.git
synced 2025-06-06 00:49:11 +02:00
Copie di backup di codice proveniente da EduINAF Tools
This commit is contained in:
52
eduinafoldcode/php/tabella.php
Normal file
52
eduinafoldcode/php/tabella.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
# nuovo shortcode per listare nella barra gli articoli di uno speciale
|
||||
function tabspeciali($atts) {
|
||||
global $post;
|
||||
|
||||
extract(
|
||||
shortcode_atts(
|
||||
array(
|
||||
'speciale' => 'null',
|
||||
),
|
||||
$atts
|
||||
)
|
||||
);
|
||||
|
||||
#tutti i termini associati all'eventuale speciale associato al post
|
||||
$terms = get_the_terms ( $post->ID, 'speciali' );
|
||||
|
||||
foreach ( $terms as $term ) {
|
||||
$term_link = get_term_link( $term, 'speciali' );
|
||||
$toc = $term->slug;
|
||||
|
||||
if ( $toc <> $speciale ) {
|
||||
$content = null;
|
||||
} else {
|
||||
$q = new WP_Query( array( 'speciali' => $speciale, 'posts_per_page'=>-1 ) );
|
||||
$header = '<h4 class="widget-title h6"><span>Gli articoli dello speciale '.$term->name.'</span></h4>';
|
||||
|
||||
if ( $q->have_posts() ) {
|
||||
while ( $q->have_posts() ) {
|
||||
$q->the_post();
|
||||
$titolo = get_the_title();
|
||||
|
||||
$content .= '<li><a href="'.get_the_permalink().'">'.$titolo.'</a></li>';
|
||||
}
|
||||
/* ripristino */
|
||||
wp_reset_postdata();
|
||||
}
|
||||
$content = '<div id="recent-posts-2" class="widget widget_recent_entries">'.$header.'<ul>'.$content.'</ul></div>';
|
||||
}
|
||||
}
|
||||
|
||||
$content = $content.$after_widget;
|
||||
|
||||
if ( get_post_type() == 'post' ) {
|
||||
$out = $content;
|
||||
} else {
|
||||
$out = null;
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
add_shortcode( 'tabspeciali', 'tabspeciali' );
|
Reference in New Issue
Block a user