Viewing version 14 created 10 months ago by livibetter.

wpOTD

Introduction

This plugin was inspired by “On this day” in Wikipedia’s home page. It can list posts which have same calendar date as today’s or as specific post’s.

Features

  • Full Customization of HTML
  • Widget Support
  • Automatic appending list – No need to add codes
  • Upcoming Old Posts Reminder in Dashboard
  • Options Page
  • Search Form – Search Posts by Partial Date
  • Complete Deactivation
  • Translations (Help Translate)

Screenshots

Widget

Appending after post

Within 7 Dates in Previous Years

Options Page h2. Demonstration

Please check this demo blog post out.

Download

Please download this plugin source in WordPress Extend, files are not provided in this project space.

Installing

  1. Copy directory !OnThisDay to wp-content/plugins (NOT directory on-this-day). You will have something like /wp-content/plugins/OnThisDay/OnThisDay.php.
  2. Activate “On This Day” in plugins page.
  3. Set options, add “On This Day” widget at sidebar, or add OTDList() to sidebar, or main post loop.

Upgrading

This section will tell you, do you need to upgrade and anything you have to pay attention while upgrading.

0.2.3 to 0.3

  • Three are two more options “Include pages” and “Exclude current year’s posts” in General Options has been added in 0.3, some behaviors may be changed.

0.2 to 0.2.1

  • Steps: Deactivate 0.2, remove 0.2, upload 0.2.1, activate 0.2.1.
  • All old options will be removed, such limit, excerpt length, etc.
  • OTDList accepts only $targetPost. You can only customize HTML using settings in Options page.

0.1 to 0.1.1

  • Just override
  • If your WP can do date search normally, then you don’t have to upgrade.
  • Upgrading to 0.1.1 can ensure including the JavaScript code only once. In another words, save little bandwidth.

Uninstalling

From version 0.5, OTD allows you to remove all settings for OTD as well as deactivation of OTD.

  • Go to OTD option page.
  • Click “Deactivate Plugin” at “Management” section on right side.
  • Remove directory !OnThisDay from plugins.

Usage

There are three ways to use this plugin.

Widget

Go to Presentation/Widgets, drag widget “On this day” from Available Widgets, then drop it onto Sidebar.

It results like (in default theme)

Note:

  • You can check Lists same calendar date posts to the post in single post mode on in Widget Options in OTD Options page, then the OTD widget will list same calendar date posts when visitor reads a single post.
  • If Include pages in General Options isn’t checked, then widget will not show on pages.

Automatically appending

You can check these two options under General Options in OTD Options page:

  • Show OTD list after single post automatically
  • Show OTD list after every post automatically

If you enable them, then the “On this day…” list will be appended right after post content.

Manually calling OTDList()

You can call OTDList() to get the list where you want to show. If you call this function within posts loop, then it will return posts which have same calendar date as current post.

For example, you can have

<?php while (have_posts()) : the_post(); ?>
[...]
    <div class="post-onthisday">
        <h2>On this day...</h2>
            <?php OTDList(); ?>
    </div>
[...]
<?php endwhile;?>

in index.php of your template. You only need to take care the title of this list, then call OTDList(). In this mode, it uses templates in Single post mode Options or Multi-posts mode Options

In sidebar.php,

<div class="sidebar-item-content">
    <?php OTDList(); ?>
</div>

This use template of Widget Options. This results posts which have same calendar date as today. If visitor is reading a single post or page and Lists same calendar date posts to the post in single post mode of Widget Options is checked, then OTD plugin will list same calendar date posts as current post or page.

Customization

OTD List Titles

You can use On %date:jS of F%... instead of On this day.... You will get something like 28th of October....

You should not use heading tags(h1, h2,...) embracing title of widget.

DIV Block

If you need OTD list within a div block, you can use <div class="onthisday"><h3>On this day...</h3> as title and [snip] %search% </div> as block.

Calling OTDList()

You can call `OTDList()` to list.


function OTDList($targetPost=null){

Exclude current year’s posts

Check Exclude current year’s post in General Options. This option also applies on pages if Include pages checked.

Date Search Form

You can turn this feature on under option page(it is activated by default). Once you turn it on, there will be a search form appended after the list.

User can select Month, Day of Month and Year in any possible combinations, include the first blank option in each part. The blank option means unspecific month, day of month, or year.

Search Form Only

If you only need search form, that means you don’t need OTD list, then you can just call GetDateSearchForm() like

<?php echo GetDateSearchForm(); ?>
to get the search form only.

Style

This form looks like

&lt;form class="dateSearchForm" id="dateSearchForm-<?php echo rand(); ?>"&gt;
    <div class="dateSearchForm">
        <select class="dateSearchMonth" name="dateSearchMonth">
            <option></option>
            <option></option>
            <option></option>
        </select>
        <select class="dateSearchDay" name="dateSearchDay">
            <option></option>
            <option></option>
            <option></option>
        </select>
        <select class="dateSearchYear" name="dateSearchYear">
            <option></option>
            <option></option>
            <option></option>
        </select>
        <input class="dateSearchButton" type="button" value="&raquo;" onclick="searchDate(this.form)"/>
    </div>
&lt;/form&gt;
You can define those styles into your stylesheet.

Additional Modification for Theme

If your theme has some code like the following, you may want to do some modifications:

<?php /* If this is a category archive */ if (is_category()) { ?>
    <h2 class="pagetitle">Archive for the &#8216;<?php single_cat_title(); ?>&#8217; Category</h2>
<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    <h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>
<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    <h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>
<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    <h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>
<?php /* If this is an author archive */ } elseif (is_author()) { ?>
    <h2 class="pagetitle">Author Archive</h2>
<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
    <h2 class="pagetitle">Blog Archives</h2>
Usually these are in archive.php theme template file, like Default Theme 1.6. You may modify it to be:

<?php /* If this is a category archive */ if ( is_category() ) { ?>
    <h2 class="pagetitle">Archive for the &#8216;<?php single_cat_title(); ?>&#8217; Category</h2>
<?php /* If this is a date archive */ } elseif ( is_date() ) { ?>
    <h2 class="pagetitle">Archive for <?php echo dateArchiveTitle(); ?> </h2>
<?php /* If this is an author archive */ } elseif ( is_author() ) { ?>
    <h2 class="pagetitle">Author Archive</h2>
<?php /* If this is a paged archive */ } elseif ( isset($_GET['paged'] ) && !empty($_GET['paged'])) { ?>
    <h2 class="pagetitle">Blog Archives</h2>
<?php } ?>
The parts of daily, monthly and yearly archives have been removed, and replaced with a much simpler code:

<?php /* If this is a date archive */ } elseif ( is_date() ) { ?>
    <h2 class="pagetitle">Archive for <?php echo dateArchiveTitle(); ?> </h2>
OnThisDay.php provides a function named dateArchiveTitle(), it will decide an appropriate date archive title, e.g.

2nd day of July in every year
in 2007
July in every year 

History Key

  • New content
  • Removed content

Recent Versions

Choose two versions to compare, or click the link to view it.

  1. 15. 9 months by livibetter
  2. 14. 10 months by livibetter
  3. 13. 10 months by livibetter
  4. 12. 10 months by livibetter
  5. 11. 10 months by livibetter
  6. 10. 10 months by livibetter
  7. 9. 10 months by livibetter
  8. 8. 10 months by livibetter
  9. 7. 10 months by livibetter
  10. 6. 10 months by livibetter
  11. 5. 10 months by livibetter
  12. 4. 10 months by livibetter
  13. 3. 10 months by livibetter
  14. 2. 10 months by livibetter
  15. 1. 10 months by livibetter