Last active
August 3, 2022 00:42
-
-
Save laacz/8188561 to your computer and use it in GitHub Desktop.
Wordpress archivi iekš laacz.lv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: Archivs | |
Šo saglabājam iekš tēmas direktorijas. Tad izveidojam ierakstu ar slug "archive" | |
vai kā nu vēlamies, tam norādam templeitu (jābūt sarakstā) "Archivs". Done. | |
*/ | |
get_header(); | |
$menesi = Array( | |
'', | |
'janvāris', | |
'februāris', | |
'marts', | |
'aprīlis', | |
'maijs', | |
'jūnijs', | |
'jūlijs', | |
'augusts', | |
'septembris', | |
'oktobris', | |
'novembris', | |
'decembris', | |
); | |
?> | |
<section> | |
<article id="archives"> | |
<header> | |
<h1><?php the_title(); ?></h1> | |
</header> | |
<?php | |
$query_string = preg_replace('/pagename=' . get_query_var('name') . '&?/', '', $query_string); | |
$posts = query_posts($query_string . '&post_type=post&posts_per_page=100'); | |
$prevy = $prevm = $prevd = false; | |
echo '<ul>'; | |
$ulopen = true; | |
foreach ($posts as $post) : | |
$post->post_date = substr($post->post_date, 0, 10); | |
list($y, $m, $d) = explode('-', $post->post_date); | |
if ($prevm != $m) { | |
echo '<h2><time datetime="' . $y . '-' . $m . '">' . $y . '. gada ' . ($menesi[(int)$m]) . '</time></h2>'; | |
// echo '<dt><time datetime="' . $y . '-' . $m . '">' . $y . '. gada ' . ($menesi[(int)$m]) . '</time></dt>'; | |
$prevm = $m; | |
if ($ulopen) echo '</ul>'; | |
echo '<ul>'; | |
$ulopen = true; | |
} | |
echo '<li>'; | |
echo '<time datetime="' . date('Y-m-d', strtotime($post->post_date)) . '" class="' . ($d == $prevd ? 'samedate' : '') . '">' . $d . '.</time> '; | |
echo "<a href=\"http://laacz.lv/$y/$m/$d/{$post->post_name}\">"; | |
echo ($post->post_title); | |
echo '</a>'; | |
echo $post->comment_count ? ' (' . $post->comment_count . ')' : ''; | |
echo '</li>'; | |
echo "\n"; | |
$prevd = $d; | |
endforeach; | |
if ($ulopen) echo '</ul>'; | |
?> | |
<nav class="adjacent-entries"> | |
<ul> | |
<li class="rew"><?php next_posts_link('« Senāki ieraksti') ?></li> | |
<li class="ffwd"><?php previous_posts_link('Jaunāki ieraksti »') ?></li> | |
</ul> | |
</nav> | |
</article> | |
</section> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment