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)
- bg_BG – Bulgarian by Yovko Lambrev
- zh_TW – Traditional Chinese
Screenshots
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
- Copy directory
!OnThisDaytowp-content/plugins(NOT directoryon-this-day). You will have something like/wp-content/plugins/OnThisDay/OnThisDay.php. - Activate “On This Day” in plugins page.
- 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
!OnThisDayfromplugins.
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)
http://groups.google.com/group/llbbsc/web/OTD-Widget.png
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.
<?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
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.
Applying Style
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 callGetDateSearchForm() like
<?php echo GetDateSearchForm(); ?>
to get the search form only.
Style
This form looks like
<form class="dateSearchForm" id="dateSearchForm-<?php echo rand(); ?>">
<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="»" onclick="searchDate(this.form)"/>
</div>
</form>
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 ‘<?php single_cat_title(); ?>’ 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 ‘<?php single_cat_title(); ?>’ 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