Advanced WordPress Usage
Introduction
WordPress is great, but it also has limitations that can quickly become annoying. There are ways to overcome these limitations, which I’m going to explain here.
Nginx Configuration
For WordPress configuration under Nginx, here’s an example:
|
|
Using JavaScript in a Post
I want to use JavaScript here to prevent my email address from being captured by spam robots. We first need to insert this in a post:
|
|
Then our JavaScript code:
|
|
And finally, we call our function:
|
|
So the full anti-spam system looks like:
|
|
Adding Unsupported Extensions
For example, I want to enable the OGV format for my blog. I’ll need to modify the file wp-includes/functions.php and add these lines:
|
|
There are two places to modify: the wp_ext2type function and the get_allowed_mime_types function.
Automatically Delete Comments from Trash
It’s possible to automatically delete comments in the trash after a specified number of days. Edit your WordPress configuration and add this:
|
|
Here, I’ve indicated that I want the trash to empty itself every 2 days.
FAQ
Failed to write file to disk
I had this small problem when I tried to upload files that were too large. Here are the different solutions to fix the problem:
- Check the owner permissions and write access on the upload folder
- Look in the file
/etc/php5/cgi/php.ini
and adjust the size that suits you:
post_max_size = 50M
upload_max_filesize = 50M
- Check the size of
/tmp
on your server (for example, my vservers are by default set to 16M, which was problematic since it’s the temporary location where WordPress stores its files)
Resources
Last updated 07 May 2013, 07:28 CEST.