WordPress Blogs with YC years, the Function! (OOC)

 

Referring back to this post:

Convert Year to YC for EVE (OOC)

I made this into a nice little function to be used on your self hosted WordPress blogs.

I actually have two functions, one is for your every day posts, the other is for your archives. The archives function will not change your sidebar archives, but I will show what I found to be the easiest way to do that at the end.

For starters, open up /wp-includes/general-template.php

Scroll all the way down to the end and paste this:

 

function yc_date() {
$ycdate = get_the_date(get_option('date_format'));

$ycdatearr = split('-',$ycdate);

$ycyear = $ycdatearr[0] - 1898;

$ycmonth = $ycdatearr[1];

$ycday = $ycdatearr[2];

$ycdate = 'YC'.$ycyear. '-' .$ycmonth. '-' .$ycday;

return apply_filters('yc_date', $ycdate);

}

function yc_arc_date() {
$ycdate = get_the_date(get_option('date_format'));

$ycdatearr = split('-',$ycdate);

$ycyear = $ycdatearr[0] - 1898;

$ycmonth = $ycdatearr[1];

$ycday = $ycdatearr[2];

$ycarcdate = 'YC'.$ycyear. '-' .$ycmonth;

return apply_filters('yc_arc_date', $ycarcdate);

}

 

 

To use today as an example, it will output as “YC112-07-16″ but by changing the order of the years and months you can make it be the order you prefer.

Now you will need to edit your theme. Find every instance of get_the_date(), there may be extra information between the parentheses that needs deleted as well, and replace it with “yc_date()” without the quotes. You will probably only find it on single.php but it may be elsewhere depending on your theme.

if you use WPTouch, change line 8 of

wp-content/plugins/wptouch/themes/default/single.php

from

 

 

 

To

 

 

 

Flexo has been updated, this no longer works. I’ve managed to get the year numbers to show right in the default archive widget, but have not been able to add on the YC. When I figure it out, I will update accordingly.

Now for the archives, open archives.php and look for “If this is a monthly archive (the theme I use only has monthly, but there may be more, and some simple changes to the yc_arc_date function can get you day or year, it’s all a matter of what you choose to include) and replace the time grabbing function with “yc_arc_date()”.

 

Now, for your sidebar archives.

 

Download Flexo Archives Widget and open flexo_archives_widget.php

Find the line that reads:

 

echo flexo_year_start($a_result->year) . "\n";

 

 

And change it to

 

 

 

echo flexo_year_start('YC' .($a_result->year - 1898)) . "\n";

 

 

Couldn’t be any easier.

On a side note, why is it I find myself writing more about ways to enhance the Mac client experience or fun stuff to do with your blog than actually what I do when playing the game? Soon… I hope.

 

  • Daniel Perch

    Like what your doing here for us Mac people. Keep up the great info.