Archive Template WordPress
Berawal dari keisengan saya membuat sebuah WordPress theme (yang kemudian saya gunakan sebagai theme di blog saya ini), akhirnya saya tergelitik penasaran bagaimana membuat sebuah halaman archive di WordPress. Sebenarnya WordPress sudah menyediakan archive shortcode untuk menampilkan postingan yang sudah diterbitkan dengan berbagai kustomisasinya. Akan tetapi saya tidak menemukan keluaran yang saya inginkan, yakni setiap postingan akan dikelompokkan berdasarkan bulan postingan diterbitkan. Entahlah, di dunia luar internet sudah ada atau belum, saya kurang tahu. Akhirnya saya buat kode saya sendiri, ya itung-itung belajar WordPress deh
Berikut kode yang saya gunakan.

WordPress Dashboard
Awalnya saya membuat berkas berjudul archives.php dengan berisi kode sebagai berikut,
<?php
/*
Template Name: Archive
*/
?>
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<div>
<div><h1><?php the_title();?></h1></div>
<div>
<?php
global $post;
$args = array( 'numberposts' => 500, 'offset'=> 0);
$myposts = get_posts( $args );
$post_date = '';
foreach( $myposts as $post ) : setup_postdata($post);
if($post_group_date != get_the_time('F Y')){
echo '<h1>' . get_the_time('F Y') . '</h1>';
}
$post_group_date = get_the_time('F Y')
?>
<a href="<?php the_permalink(); ?>">
<div>?php the_time('j'); ?> — <?php the_title(); ?></div>
</a>
<?php endforeach;?>
</div>
</div>
<?php endwhile; endif; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Setelah itu saya membuat sebuah halaman kosong dengan judul `Archive` dengan menggunakan page template bernama Archive. Boom! you have your archive which contains all of your posts (max. 500) grouped by month
Good luck!
Related posts:
thanks gan atas tutornya akan saya coba. mudah2han berhasil