/** * Ustvari array z leti, v katerih obstajajo objave **/ function get_posts_years_array($post_type='obcasne-razstave') { global $wpdb; $result = array(); $years = $wpdb->get_results( $wpdb->prepare( "SELECT YEAR(post_date) FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type = %s GROUP BY YEAR(post_date) DESC", $post_type ), ARRAY_N ); if ( is_array( $years ) && count( $years ) > 0 ) { foreach ( $years as $year ) { $result[] = $year[0]; } } return $result; }