Oct
22

Wordpress Hacks

Posted in Tutorials, Web + CSS |

I’ve been putting off upgrading to the latest version of Wordpress as I’ve made some slightly hacky changes to a few of the files which I haven’t kept a proper record of, and inevitably forget to back up before upgrading. But not this time! I have now backed up everything and will put a list of my hacks here, for my future reference and for anyone who feels a bit limited by Wordpress’s templates.

Giving the category listing ‘before’ and ‘after’

I’m honestly not sure why the ability to put in what you want to appear before and after categories isn’t Wordpress by default. All I wanted to do is put those little dots in between the category items to make it the same as the archives listing – which actually does have the ability to choose what goes before and after each item.

After a lot of Googling I eventually came across this tutorial which hacks a few Wordpress files to enables wp_list_categories() to do exactly what I wanted it to. Now I (and you) can add dots, random tags and whatever you like between categories!

Removing the year from archives listing

Listing the year after every month in the archives listing wp_get_archives() seemed a bit pointless to me, especially when it’s listed horizontally the way I have it above. There doesn’t seem to be a way to remove it or change the date format, so again I had to turn to a hacky solution.

Open wp-includes/general-template.php

Around line 431 you should find the following:

$text = sprintf(__(’%1$s %2$d’), $wp_locale->get_month($arcresult->month), $arcresult->year);

See the %2$d part? That’s putting in the year, so replace with:

$text = sprintf(__(’%1$s’), $wp_locale->get_month($arcresult->month), $arcresult->year);

No more year!

Now I’m not saying that these are the best methods for creating a Wordpress template – they’re hacks, prone to problems whenever you upgrade, but the best solutions that I could find to achieve the look that I wanted. If anyone knows a better method of achieving this I’d be grateful if you could tell me so I don’t have to remember what to change every time I upgrade!

Leave a Reply

your name

your email

your website url