Support » Plugins » Show WordPress posts by quarter?

  • How would I list an author’s WordPress posts by quarter in author.php?

    Current relevant author.php code is as follows (post is custom type “press mentions”, FYI).

    This presents a single list of all this author’s posts. But how do I break this list up in to segments, with quarterly headers, ie. “2015 Q3”, “2015 Q4″, 2016 Q1”, “2016 Q2”?

    Quarters are four three-month periods running from January 1.

    Posts should appear in same order as present, but segmented by quarter. So, the latest quarterly heading appears at top and so forth.

    <!-- Press appearances -->
        <?php
          // Count press appearances
          $post_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '" . $curauth->ID . "' AND post_type = 'pressmention' AND post_status = 'publish'");
        ?>
        <h5><?php echo '<span class="label label-primary">'.$post_count.'</span>'; ?> Media appearances:</h5>
        <table class="table table-striped table-sm">
          <tbody>
          <?php // Show custom post list - http://wordpress.stackexchange.com/questions/178739/displaying-custom-post-types-in-author-php
              $args = array(
              'post_type' => 'pressmention' ,
              'author' => get_queried_object_id(), // this will be the author ID on the author page
              'showposts' => 200
          );
          $custom_posts = new WP_Query( $args );
    
          if ( $custom_posts->have_posts() ): while ( $custom_posts->have_posts() ) : $custom_posts->the_post();?>
          <tr>
            <!-- changed th, removed scope="row", was width="110" and "125" -->
            <td class="col-xs-2"><?php the_time('M d, Y'); ?></td>
            <td class="col-xs-3"><img src="https://plus.google.com/_/favicon?domain=<?php echo get_post_meta( $post->ID,'press_mention_information_publication-url',true); ?>" alt="Publication"> <?php echo get_post_meta( $post->ID,'press_mention_information_publication-name',true); ?></td>
            <td class="col-xs-7"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></td>
          </tr>
          <?php endwhile; else: ?>
              <!-- changed th, removed scope="row" -->
              <tr><td colspan="2">No posts.</td></tr>
          <?php endif; ?>
          </tbody>
        </table>
  • The topic ‘Show WordPress posts by quarter?’ is closed to new replies.