Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if(is_category() or is_single() or is_tag()) { ?>
- <div class="widget pink fl100">
- <h3>Arkiv</h3>
- <div class="yearly-archive">
- <?php
- $current_category = single_cat_title("", false);
- $this_category = get_category($cat);
- $currentcat = $this_category->category_nicename; ?>
- <?php
- $oldest = get_posts( 'post_type=post&post_status=publish&posts_per_page=-1&order=ASC' );
- $oldest_date = $oldest[0]->post_date;
- $first_date = date('Y', strtotime($oldest_date));
- $todays_date = date('Y');
- $year_range = range($todays_date, $first_date);
- foreach ($year_range as $year) { ?>
- <div class="select-year<?php if($todays_date == $year) { ?> active<?php } ?>" data-year="<?php echo $year; ?>"
- ><?php echo $year; ?>
- </div><!-- .select-year -->
- <?php }
- foreach ($year_range as $year) { ?>
- <div class="year"<?php if($todays_date == $year){?> style="display:block;"<?php }?> data-year="<?php echo $year; ?>">
- <?php $args = array(
- 'posts_per_page' => -1,
- 'post_type' => 'post',
- 'post_status' => 'publish',
- 'year' => $year,
- 'category_name' => $currentcat
- );
- $months = array(
- '01' => 'Januari',
- '02' => 'Februari',
- '03' => 'Mars',
- '04' => 'April',
- '05' => 'Maj',
- '06' => 'Juni',
- '07' => 'Juli',
- '08' => 'Augusti',
- '09' => 'September',
- '10' => 'Oktober',
- '11' => 'November',
- '12' => 'December');
- $mentioned_months = array();
- $first_month_done = false;
- $yearly_posts = new WP_Query($args);
- if($yearly_posts->have_posts()) {
- echo '<ul class="arkiv">';
- while($yearly_posts->have_posts()) {
- $yearly_posts->the_post();
- $month_num = get_the_time('m');
- $month = $months[$month_num];
- if (!isset($mentioned_months[$month_num])) {
- $mentioned_months[$month_num] = 1;
- if ($first_month_done) { ?>
- </div> <!-- .year -->
- <? } ?>
- <div class="toggle_month fl100" data-month="<?= $month_num ?>"><?= $month ?></div><!-- .toggle_month -->
- <div class="month_post_container fl100" data-month="<?= $month_num ?>">
- <?php
- $first_month_done = true;
- }
- ?>
- <div class="arkivpost">
- <span class="post_title">
- <a href="<?php the_permalink() ;?>">
- <?php $title = strip_tags(get_the_title()); if (strlen($title) >= 28) {
- echo mb_substr($title, 0,28, 'utf-8'); echo '...'; }
- else {
- echo $title; } ?>
- </a>
- </span>
- </div><!-- .arkivpost -->
- <?php }echo '</ul></div>';
- }
- }
- wp_reset_query(); wp_reset_postdata();
- ?>
- </div>
- <!-- .yearly-archive -->
- </div>
- <!-- .widget -->
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement