Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save celticwebdesign/579c22b19e692030beae5ee36f934dbe to your computer and use it in GitHub Desktop.
Save celticwebdesign/579c22b19e692030beae5ee36f934dbe to your computer and use it in GitHub Desktop.
<?php
// https://wordpress.stackexchange.com/a/152012
// How to show monthly archive posts?
// this can be used for many other archive pages, see the link above.
if (is_category()) {
/* If this is a category archive */
$cat = get_query_var('cat');
$category = get_category($cat);
$taxonomy = 'category="'.$category->slug.'"';
} elseif( is_tag() ) {
/* If this is a tag archive */
$tag = get_query_var('tag');
$taxonomy = 'tag="'.$tag.'"';
} elseif( is_month() || is_year() ) {
/* If this is a monthly archive */
$year = get_the_date('Y');
$month = get_the_date('m');
}
?>
<div class="wrapper" id="archive-wrapper">
<main class="site-main" id="main">
<section id="news__alm_news">
<div class="container">
<div class="page-title">
<?php
the_archive_title( '<h1 class="page-title">', '</h1>' );
?>
</div>
<?php
if (is_category() || is_tag()) {
echo do_shortcode('[ajax_load_more post_type="post" posts_per_page="6" '.$taxonomy.' scroll="false" transition_container_classes="row" images_loaded="true"]');
}
elseif( is_year() ) {
echo do_shortcode('[ajax_load_more post_type="post" posts_per_page="6" year="' . $year . '" scroll="false" transition_container_classes="row" images_loaded="true"]');
}
elseif( is_month() ) {
echo do_shortcode('[ajax_load_more post_type="post" posts_per_page="6" year="' . $year . '" month="' . $month . '" scroll="false" transition_container_classes="row" images_loaded="true"]');
}
?>
</div>
</section>
</main><!-- #main -->
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment