A few notes on using/customising WordPress.
Plugins
A list of WordPress plugins I have developed.
Ensuring a fast WordPress website
A few thoughts on WordPress performance.
Adding a contact form
These instructions tested under WordPress v2.7.1
I would recommend the plugin Contact Form 7 for adding a contact form to a Wordpress site. I also have a few tips for improving the form output.
Moving a WordPress installation
These instructions tested under WordPress v2.0.2 – 2.9.2
If you move the installation, you may lose the ability to login to the admin area.
This SQL query will restore functionality, by correcting the relevant URL options:
update wp_options
set option_value = 'http://newsitelocation.com/goes/here/'
where option_name = 'home' or option_name = 'siteurl';
If your Wordpress installation is not in the same directory as your home page, you will need to set these options to different values:
update wp_options
set option_value = 'http://newsitelocation.com/wordpress/'
where option_name = 'siteurl';
update wp_options
set option_value = 'http://newsitelocation.com/'
where option_name = 'home';
NOTE: your options table may have a different prefix, the default is ‘wp_’.
Disabling WordPress’ slap-happy approach to <br /> tags
These instructions tested under WordPress v2.0.2
WordPress loves to add <br /> tags all over the place. To stop the madness, open
this file: /wp-includes/functions-formatting.php and change the following line (around line 57) from:
function wpautop($pee, $br = 1) {
to:
function wpautop($pee, $br = 0) {
This doesn’t remove any functionality, it just sets the default WordPress behaviour to not add <br /> tags
everywhere.
Ensuring that WordPress’ keeps <code /> blocks sacred
These instructions tested under WordPress v2.0.2
If you leave a blank line in a code block, WordPress will helpfully
add <p></p> tags in.
This will mess up your code (and invalidate your HTML!)
If you want your code blocks to be sacred, open this file: /wp-includes/functions-formatting.php
and find the following line (around line 76):
$pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</pre>' ", $pee);
Then add the following line underneath, like this:
$pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</pre>' ", $pee);
$pee = preg_replace('!(<code.*?>)(.*?)</code>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</code>' ", $pee);
Now WordPress will treat code blocks with the same degree of respect you do.
Preventing WordPress from adding <p> tags completely
If you are a HTML control-freak, you can prevent WordPress from adding any nasty <p> tags
to your posts.
Open this file: /wp-includes/functions-formatting.php
and find the following line (around line 65):
$pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
Then comment the line out (with or without the maniacal comment):
# NO MORE NASTY <p> TAGS!!! buahh haa haa haa
# $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
Now you have complete control over your HTML.