Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save celticwebdesign/579c22b19e692030beae5ee36f934dbe to your computer and use it in GitHub Desktop.
Save celticwebdesign/579c22b19e692030beae5ee36f934dbe to your computer and use it in GitHub Desktop.

Revisions

  1. celticwebdesign renamed this gist Aug 5, 2019. 1 changed file with 0 additions and 0 deletions.
  2. celticwebdesign created this gist Aug 5, 2019.
    66 changes: 66 additions & 0 deletions WordPress Archive page
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,66 @@
    <?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>