An "on this day" plugin for WordPress

Just me scratching my own itch. I want to create an RSS feed of all the blog posts which I'd published on this day in the past.

For example, if today is 21st of November 2016 then this plugin will show blog posts written on

  • 2015-11-21
  • 2014-11-21
  • 2013-11-21

And so on.

You can view a demo at

Screenshot of an RSS feed


The code is pretty simple. The WordPress API is fairly easy to get on with.

Plugin Name: OnThisDay
Description: RSS feed of posts which occurred on this day in the past
//  RSS of today's historic blog posts
//  Visible at
add_action( 'init', 'edent_on_this_day' );
function edent_on_this_day()
      if( isset( $_GET['on_this_day'] ) ) {
        $today = getdate();
        $args = array(
           'date_query' => array(
                 'month' => $today['mon'],
                 'day'   => $today['mday'],
        $query = new WP_Query( $args );
function rss_encode($data) {
    $today = getdate();
    $pubDate =  date("D, d M Y") . " 00:00:00 GMT";
    $rss = '<?xml version="1.0" encoding="UTF-8" ?>
            <rss version="2.0" xmlns:atom="">
                   <title>On This Day</title>
                   <link>' . site_url() . '/?on_this_day</link>
    $posts = $data->get_posts();
    foreach($posts as $post) {
        // Do your stuff, e.g.
        $title= $post->post_title;
        $id  = $post->ID;
        $link = get_permalink($id);
        $date = $post->post_date;
        $postDate = date("D, d M Y") . " " . date("h:i:s O", strtotime($date));
        $thumb = get_the_post_thumbnail($id, 'full');
        $archive = "From the " . date("F Y", strtotime($date)) . " archives: ";
        //  Only add an item if it is before *this year*
        //  AND before the current hour (prevents suddenly adding loads of posts)
        if (
              ( intval(date("Y", strtotime($date))) <  intval($today['year'] ) ) &&
              ( intval(date("H", strtotime($date))) <= intval($today['hours']) )
        ) {
                $rss .= '<item>
                   <title>'  .html_entity_decode($archive . $title).'</title>
                   <link>'   .htmlspecialchars($link).'</link>
                   <guid>'   .htmlspecialchars($link).'</guid>
    $rss .= '</channel>
    header('Content-Type: application/rss+xml');
    echo $rss;

The latest versions of the source code is at



The entries in the RSS feed are generated on an hourly basis.

For example, if the time is 1300 the RSS feed will only show blog posts published on or before 1300 on their original publication day.

This allows services like IFTTT to post the feed to Twitter throughout the day rather than all at once.


This plugin lives at The results are not cached.


The thumbnail from the post is also included. If there is no thumbnail, services like IFTTT might misbehave:

Times and Locale

The RSS feed is hardcoded to GMT and en-GB - this may change in the future.


I'm using IFTTT to post to Twitter. Ideally, I'd use JetPack Publicize to syndicate it to Facebook, LinkedIn, and others.


I'm not releasing this into the WordPress plugin ecosystem because their system confuses me. You can install it in /wp-content/plugins/onthisday/ and then activate it as normal.

You can download the plugin from GitHub

Leave a Reply

Your email address will not be published. Required fields are marked *