bluvertigo
1/27/2016 - 4:48 PM

Etichette con date dell'anno del post / Get label for year publis post

Etichette con date dell'anno del post / Get label for year publis post

.tags li {
  list-style:none;
  display:inline-block;
  background-color:#3E3E4A;
  border-radius:5px;
  padding:5px 10px;
  font-size:18px;
  color:#B2BAC2;
  box-shadow:0px 0px 4px black;
  margin:3px 2px 3px 1px;
  line-height:27px;
}

.tags li a { color: white; }
<?php
$archi = wp_get_archives( 'type=yearly&echo=0' );
		$archi = explode( '</li>' , $archi );
		$links = array();
		echo '<div class="tags"><ul>';
		foreach( $archi as $link ) {
			$link = str_replace( array( '<li>' , "\n" , "\t" , "\s" ), '' , $link );
			$link = str_replace( "'", '"' , $link );
			if( '' != $link ){
				$curr_year = strip_tags($link);
				$my_query = new WP_Query('year='.$curr_year.'&posts_per_page=-1&category_name=offerte');
				$count = $my_query->post_count;
				echo "<li>" . preg_replace('/href="[^"]*/', '\0?category_name=offerte', $link) . " (" . $count . ") </li>";
			}
			else
				continue;
		}
		echo '</ul></div>';
?>