Uploading media to old posts in WordPress backdates the file location

From the ashes of b2/cafelog

I first started using WordPress in 2003 not long after it had been forked from b2/cafelog. It was version 0.7, before they started using jazz-inspired code names for the releases.

  • There were no pages, only posts. Pages arrived in 2005, version 1.5 Strayhorn.
  • There was no plugin architecture: if you wanted to make changes to the functionality of the application then you had to edit the core files (and re-edit them every time you updated WordPress… which was all done manually, of course). Plugins arrived in 2004, version 1.2 Mingus.
  • There were no themes. Support for that also arrived in 2005, version 1.5 Strayhorn, and was greatly improved in 2010, version 3.0 Thelonious.

The media library was also very basic in those days. You actually had to add the absolute path of the media folder in your b2config.php file, like this: $fileupload_realpath = '/home/example/public_html/images';

Organize media into folders

The media library improved over the years but one thing I never got around to switching on was this one, now found in Settings > Media: “Organize my uploads into month- and year-based folders”. I kind of wish I had now, because I have nearly 3,680 images sitting loose in /wp-content.

As part of my site migration from blog.garethjmsaunders.co.uk to www.garethjmsaunders.co.uk/blog I am trying to plan the best way to move all these images into month- and year-based folders. If you have any thoughts please do leave them in the comments.

What I did discover, however, is that if I were to retrospectively upload an image today to the media library, say for a blog post dated 9 August 2007, WordPress will upload it to a directory for the month associated with the post (/wp-content/uploads/2007/08/) and not the month I actually uploaded it (May 2014).

However, the media library filter still lists the file as having been uploaded during May 2014.

According to this support ticket “#10752 Uploading new media to existing posts/pages backdates file location” this is a feature, not a bug. It would be rather nice if you could choose which convention it uses: I’d prefer to be able to filter images according to when the image was used on a post, rather than when I ‘fixed’ the image.

Workaround to get a /blog site on WordPress multisite

The following words are reserved for use by WordPress functions and cannot be used as blog names: page, comments, blog, files, feed

Last month I said that I would soon be redesigning and re-architecting my website, including this blog. It has now begun!

Losing the subdomains

Something I want to do is standardise the URLs used on the site. Once upon a time I had an idea of using subdomains for all my mini-sites, so

  • blog.garethjmsaunders.co.uk
  • blueprint.garethjmsaunders.co.uk
  • mahjong.garethjmsaunders.co.uk
  • psion.garethjmsaunders.co.uk

I got as far as setting up my blog on a subdomain and I changed my mind. (Or got lazy, I can’t remember now.) 11 years later I have now decided to bite the bullet and move from blog.garethjmsaunders.co.uk to garethjmsaunders.co.uk/blog. It’s potentially going to involve a lot of work (and a little .htaccess wrangling) but it will be worth it in the long run.

WordPress doesn’t like blog sites

My plan was to create a new sub-site called “blog” but when I set up a WordPress multisite installation on my local machine to test how this would all work I encountered an unexpected problem. When you try to create a new site called “blog” WordPress multisite returns this error message:

The following words are reserved for use by WordPress functions and cannot be used as blog names: page, comments, blog, files, feed

Ah!

Workaround

The workaround I worked out, however, is pretty simple:

  1. On the WordPress multisite default site, create a new page called “Blog”, with the URL of ‘/blog’. (On my localhost test site this has a URL of http://garethjmsaunders.shed/blog/.)
  2. In Settings > Reading set the posts page to be your new “Blog” page.
  3. Now import your blog into this site. (I imported it category by category, one at a time as I have a lot of posts.)

Of course, if you want your blog to use a different theme than the rest of the default site pages you will need to use a multiple theme plugin.

WordPress 3.0.1 not publishing scheduled posts

Clock mechanism

Back in May I published a post about WordPress 2.9 not publishing scheduled posts. Recently I did an automatic update to WordPress 3.0.1 … and guess what: scheduled posting has been broken once again.

I’ll try the method I used before, which was to delete all the core WordPress files and upload them again manually, but in the meantime I found this WordPress plugin has done the job: Missed Scheduled.

By default the plugin is set to run every 15 minutes, but I’ve changed mine to 2 minutes by editing line 12:

12
define('MISSEDSCHEDULED_DELAY', 2); // Number is in minutes, change it according to your needs

If it turns out that uploading the files manually fixes the issue again I guess I’ll be running manual upgrades in future.

WordPress 2.9 not publishing scheduled posts

Clock mechanism

On Tuesday night I scheduled a post to publish at 08:30 on Wednesday morning. It didn’t happen. Did it have a broken clock, or something?

So I tried to reschedule it. That would surely wor… No! That didn’t work either.

In fact, no matter what I did I just couldn’t get scheduled posts to publish. I would just get a message in my list of posts saying “Missed Schedule”. It turns out I’m not the only person.

I patiently went through every suggestion offered, and not one of them worked. I updated core files (http.php and cron.php) to no effect. I disabled all my plugins. Still nothing.

Other installations

In the end I installed another instance of WordPress 2.9.2 and the latest beta version of WordPress 3.0 (beta 2) and tested those. And guess what: scheduling worked!

Solution

So my solution was to backup everything (blog files and MySQL database), delete all the old files off the server and re-upload them.

Maybe, I reasoned, after the last automatic upgrade something went amiss. Maybe certain key files weren’t overwritten correctly or indeed uploaded at all.

That did the trick. I kind of wished that I’d tried that first. But you live and learn, I guess.

WordPress upgrade: filling in the missing pieces

Missing piece

Well, where to start?

I’ve been meaning to blog about life for ages but since Reuben and Joshua were born in November 2008 other things took more of a priority.  Things like attending to twin boys, eating, getting enough sleep, and generally trying to muddle through the days.  I’ll likely write more about that in the future.

Simplifying life

Over the last few months I’ve been working at simplifying life as much as possible, and being a good Getting Things Done / Take Back Your Life disciple and disengaging from projects and tasks that I knew I wouldn’t/couldn’t complete or which were no longer priorities.  It’s felt good.

That’s given me more of a focus on the things that I do want to do.  Sorting out my web server was one of those things.

Server upgrade

I suspect that I would have blogged more about it at the time (and I now wish that I had) but I made a promise to myself that I wouldn’t blog again until I’d upgraded my server.  Of course, that took a good few months longer than I had anticipated (doesn’t everything these days?).

In February I moved from Webfusion to Heart Internet, after an abortive attempt to simply upgrade to a better hosting package at Webfusion.  The killer feature that was missing from the Webfusion package was subdomains; I didn’t want to lose my blog.garethjmsaunders.co.uk URL that I’d just had printed onto a custom-made laptop skin.

So far my experience of Heart Internet has been excellent.

Upgrade WordPress

The most pressing reason for moving to a better server was to enable me to upgrade WordPress, the software that manages my blog.  My old host had a bunch of really out-of-date features (MySQL 3.2 and PHP4) which just wasn’t enough to run the latest versions of WordPress.  What a relief to be able to upgrade from WordPress version 2.0.11 to the latest version 2.9.

And wow! there have been quite a few changes to WordPress in the interim: the addition of widgets and tags, as well as critical changes to the main API, a much nicer UI, etc.  So many changes in fact that my old theme broke.  So that had to be fixed.

The upgrade was pretty pain-free thanks to WordPress’s infamous 5-minute install and upgrade script.  (I tested it out first, of course, on my localhost machine using XAMPP.)  The only thing that I missed was matching the database character set encoding.  It was set to ISO-8859-1 (Latin-1) rather than UTF-8 (Unicode) so there are still a few odd character combinations on the blog that I need to track down.

Batch categories

WordPress now has tags.  Back it the day it only supported categories so I, like many other WordPress users, created tens of categories to organise what I was writing about.  I had 88 categories.

I found a tremendous plugin called Batch Categories which let me quickly (by which I mean over the course of two days, rather than weeks if I had to edit each post individually) move groups of posts from one category to another, and also add tags to groups of posts.

So I took the easy route of replacing most of the categories I had with tags and rationalising my categories down to nine:

  1. Books
  2. Computer
  3. Family
  4. General
  5. God Project
  6. Mah Jong
  7. Music
  8. Psion
  9. Web

Next …

I’m really keen to redesign my blog theme but I’m going to hang off on that for the time being.  I’ve got a couple of other things that I want to complete first.

CSS framework

The first thing is to complete work on what started as a plugin for the Blueprint CSS framework and which is now turning out to be a combination of different parts of my favourite CSS frameworks.

Website redesign

Once that’s done I’m going to work on a complete reworking of my main website www.garethjmsaunders.co.uk.  The last time I did any serious work on it was, I think, probably around 2003.  The code has a very serious dose of ‘classitis‘.

One of my biggest drivers is the number of emails and telephone calls that I still get for information about and software for the Psion range of PDAs.  I want to create some space for myself by putting a lot more of that information on my site, in a way that it can be found more easily.

Getting the WP-Syntax plug-in to work in WordPress 2.0.x

Plugin
Vintage socket photo by porah

I was looking for a WordPress plugin for code syntax highlighting that would work in the legacy WordPress 2.0 branch and discovered WP-Syntax which promised to do the trick.

The system requirements say

  • Requires WordPress Version: 2.0 or higher
  • Compatible up to: 2.7

Except that when installed on a WordPress 2.0.11 installation it threw up an error:

Fatal error: Call to undefined function do_action_ref_array() in \blog\wp-content\plugins\wp-syntax\wp-syntax.php on line 106

Tweaking required

It looks like that plugin doesn’t work in WordPress 2.0.x without a little tweaking. The exceptional WordPress Codex came to the rescue — if only all content management system documentation was that good.

This function is identical to do_action

So I tweaked the code and removed:

106
do_action_ref_array('wp_syntax_init_geshi', array(&$geshi));

and replaced it with

106
do_action('wp_syntax_init_geshi', array(&$geshi));

and lo and behold it worked!

Smarter web design article in .net magazine

Smarter and faster web design

The current edition of .net magazine (October 2008, issue 181) has an interesting feature article entitled “Smarter and faster web design”.

Magazine writer Craig Grannell promises “you don’t need to work harder, or for longer hours, to get better results. You just need to work smarter!” A sucker for productivity tips here’s my take on what he has to say:

1. Get away from the computer

This is one my favourites, and one that I use all the time. Well, not all the time, otherwise you’d never find me at my desk!

Lateral‘s Simon Crab offers this thought:

“… today’s web designers have a subconscious belief that the computer will provide an answer as long as they sit in front of it for long enough”

Instead of sitting staring at your design software of choice (Photoshop, Paint Shop Pro Photo, Publisher, Illustrator, Visio, etc.) he suggests going out and get a different perspective on the world. Go to exhibitions, browse magazines at the newsagent, walk around and look around you.

I can’t remember where I first learned this, but it’s been really helpful advice. Get inspiration from other non-Web environments. I’m forever ripping out pages from magazines, scanning them or simply gluing them into a scrapbook. I’ve found inspiration in books, magazines, TV, architecture, fashion, nature … step away from the computer!

2. Explain the idea to a non-techie

I don’t know how many times Jane has patiently sat and listened to me wittering on about some design idea, and then pondered carefully as I finish with the killer question “Does that make sense?”

Crab notes:

“A foolproof test is verbally explaining an idea to a non-designer. If you can’t succinctly explain a concept and get across how it will look and feel, it’s probably not a great idea.”

3. Paper and a pen

This was a tip that struck a chord with me: use simpler tools. Don’t rely on massive, expensive software applications. Get back to basics.

I have a home-made pad of A5 paper next to me on my desks, both at work and at home. Any scrap A4 paper that would otherwise go into the recycling box gets ripped in two and bound together with a foldback clip.

The next bit of advice is from usability guru Jakob Nielsen:

The most important tools for a smart designer are a pen and plenty of paper. This is all you need to do user testing — no fancy lab required. Just sit next to a customer as they attempt to use your website.

Mock things up on paper first. Show it around. Get the big things right first, before you waste time writing code that might never be used.

And for those who say “I can’t draw” advice from GapingVoid:

They’re only crayons. You didn’t fear them in kindergarten, why fear them now?

4. Simpler software

37signals founder Jason Fried:

[Our software products] do a few things really well and get out of people’s way. And when products do a few things really well, they’re more pleasant to work with, and easier to learn and understand.

Find software that does this for you. A few of my favourites:

I use these applications again and again for specific tasks because they’re quick, simple to use and reliable. I’ve got other, bigger applications that will do these tasks but these do it for me quickly.

5. Getting Things Done

Interesting advice from Khoi Vinh from NYTimes.com about GTD:

Unless you really feel GTD is perfect for you, don’t bother. It’s over-rated and just about the (admittedly satisfying) pleasure of organising a system for getting things done, rather than actually getting things done.

I can see that, but I would also say: don’t reject it simply because it doesn’t work for other people. Give it a go, and adopt the things that do work for you, such as a zero-inbox policy.

I was impressed with Andy Budd’s approach to email. He answers emails that take under five minutes, deletes the junk and then files the rest in folders with titles such as:

  • Action
  • Hold
  • Respond
  • Waiting

I’ve been inspired to try something similar.

6. Reuse code

Re-use tried and tested modules of code, for example:

  • Frameworks for CSS, PHP, JavaScript
  • Base it on the default WordPress code (clean, valid and well-structured code)
  • Create your own library of code (many code editors allow you to store these as snippets)

I loved Edward Barrow’s reason for using prebuilt libraries:

He likens using a prebuilt library to “getting an expert programmer to work on your project for free”.

Whenever I do something new I now ask myself whether this is something that I’m likely to need again. If it is I’ll store it as a snippet in WeBuilder 2008, my main code editor.

I categorize everything and have folders and subfolders in my code library arranged like this (I’ve expanded the HTML folder):

  • Apache
  • CSS
  • htaccess
  • HTML
    • !DOCTYPE
    • Basic Tags
    • Elements
    • Forms
    • IE Conditionals
    • Meta
  • JavaScript
  • jQuery
  • Lorum Ipsum
  • Microformats
  • PHP

I’ve got all sorts of goodies in here, that I don’t have to go searching for because I know they are there at my fingertips.

7. Source control

Before I discovered Subversion I used to create my own version control system. But I ended up with umpteen files and folders along the lines of:

[backup-070620]
[backup-070621]
index2.html
index3-test.html

It got ugly, and if I made a mistake or needed to roll back to a previous version I couldn’t very easily do it. I then discovered FileHamster but I couldn’t quite get the hang of it. I found it a little too intrusive.

I was then introduced to Subversion, and discovering that you don’t need to incorporate it into Apache server I installed the Subversion server onto my PC at home and it’s been great! I use the TortoiseSVN client.

Quoting once again from the article in .net:

“In fact, the simplest and smartest investment you can make for any project is to use some sort of version control system,” says Aral Balkan, web developer and conference organiser.

What are your tips?

What are the tools, tips that you find most useful, that make you most productive?