5 WordPress tips I’ve picked up

5 WordPress tips I’ve picked up

Written on: 29/04/2015

I’ve been working with WordPress for as long as I can remember (well, not technically, but you get what I mean). There are loads of things I’ve picked up along the way, that seem like second nature to me – but I’ve realised that some of my fellow developers don’t know all of these little helpful tidbits – they probably know a ton of their own instead to be fair.

I thought I would share this list of general WordPress stuff I’ve used over the years and if it helps one other freelance web designer or web developer, then that’s great.

1. WordPress Post Revisions.

These are fantastic and really very useful if you have the need for them – BUT, most of my clients don’t need the feature, or they’d only like to go back one or two revisions in case of emergency. So you can easily remove the feature, or limit the revisions by adding the following code to your config file:

// To remove revisions
define( 'WP_POST_REVISIONS', FALSE );

// To limit them
define( 'WP_POST_REVISIONS', 5 );

2. Show a relative date for comments

If you use the human_time_diff() function, you can quickly turn your comment dates into relative dates, similar to the way Twitter do it – with the whole ‘Posted 5 minutes ago’ look. This code will sort it out:

$rf_diff = human_time_diff( '2012-05-05 12:05:00', '2012-05-05 12:10:00' );
echo ‘Comment Posted: ' . $rf_diff . 'ago';

// This gives you: Comment Posted: 5 minutes ago

3. WPAutoP – a great function

WordPress will automatically wrap your content and excerpts into P tags, but you can use it pretty much wherever you like in your code. It basically takes double line breaks and stuffs them into P tags.

$rf_text = ‘Hello and welcome to my site.

I’m a freelance web designer from London and I love WordPress.

I also love Ninjas!’;

echo wpautop( $rf_text );

And yes, you can remove this feature from the_content and the_excerpt as default, just do this:

remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

4. Don’t downgrade your images on upload

You know that WordPress doesn’t use 100% quality for images, as it saves on space? Well, that’s great and all, but some sites require nothing less than 100% quality. It’s a very easy fix, just open up your functions file and whack this in there:

function rf_image_quality() {
   return 100;
}
add_filter( 'jpeg_quality', ‘rf_image_quality’ );

5. WordPress has a TON of built in scripts – so use them!

I used to constantly deregister the built in JQuery script and start adding a ton of my own scripts too, but it turns out, that you really don’t need to do that.

WordPress has so many great built in scripts, and you can hook into them – so you should. Check out the full list here: http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress

It saves you having to load in extra scrips when you really don’t need to – like ThickBox for instance, that’s in there. Just hook into it.

Obviously you need to be aware that any update to WordPress may end up with the script being removed – so it’s worth checking any future updates before you do them, but on the whole, it’s worth it.

Let's work together on your project.

Have I made an impression?

If so, then why not take the next step, which is a totally free indicative quote calculator. My hand coded algorithm asks you a few simple questions, and then will be able to give you a ballpark figure that we can use as a jumping off point for your project. Get a free quote now