Word Press Tweaks

Share This:

If you like my work and don’t want to see ads help me fund this blog by becoming a Patron
If you have a Word Press site you may find that you will need to tweak it at times. You may even need to tweak it several times a year. Here I will talk about maintaining your site with plugins and tweaks.

Backup Word Press

You should always backup your Word Press site. I usually back it up after every post and before I apply updates or add plugins. There are many ways to do this. You can backup the site by simply copying all the files and exporting the database, like the following.

tar -zcvf mywordpresssite.tar.gz wordpresssite
mysqldump -u username -p wordpressdb > wordpressdb.sql

Replace username with your mysql username you can find out the username and password by looking at your wordpress wp-config.php file in a text editor.

Now if you want you can make the process easier by creating a PHP script.

function gzCompressFile($source, $level = 9){
$dest = $source . '.gz';
$mode = 'wb' . $level;
$error = false;
if ($fp_out = gzopen($dest, $mode)) {
if ($fp_in = fopen($source,'rb')) {
while (!feof($fp_in))
gzwrite($fp_out, fread($fp_in, 1024 * 512));
} else {
$error = true;
} else {
$error = true;
if ($error)
return false;
return $dest;

Or you can use a plugin. A good plugin to use is All in One WP Migration.

Enable Caching

There are some parts of your site that rarely ever change. You can enable caching to speed up word press. This will save pages that don’t change in memory allowing Word Press to load faster.

To enable caching you can find a caching plugin. I recommend using Comet Cache.


Since your Word Press website obviously loads every time someone visits the site. It takes up server resources and bandwidth, which can also be a result in your site slowing down. To help with taking up resources on the server, you can use a CDN service. I wrote about CDN’s and how they can be used to help protect your site. This is another way a CDN can benefit you.

Minimize Code

The more code you PHP site has the slower word press becomes. Unfortantly you can’t just remove all the code because then your site will just be boring black and white with no media. However you can bunch all your code together, in a few lines.

Now bunching code up in a single line can become tedious. So we can use a plugin like Auto Optimize.

When we install Auto Optimize we will be able to minimize HTML, CSS, JS and PHP code we can do this by going into the Auto Optimize settings. Settings > Autoptimize.

Optimize Database

Word Press has an annoying way of saving all your revisions. Pretty much it makes a new entry in the MySQL database. This makes the database grow much bigger much faster as well as slows the site down. And if you never plan on using your old versions of your post, and only use your latest revisions, you can clean up the database by using the following MySQL command.

DELETE FROM wp_posts WHERE post_type='revision';

Now if you don’t want to type the above MySQL comand in all the time, you can make a PHP script to do it for you.

include 'wp-config.php';
$delete = "DELETE FROM wp_posts WHERE post_type='revision';
mysqli_query($conn, $delete);

If your not comfortable with the above methods you can always search for a plugin that does just this. A good plugin that achieves this and more is WP-Optimize.

WP Optimize

When using WP-Optimize be very careful when using the options that are in red.

Images And Media

Images and media in general are what people want these days. Unfortunately the more media you have the slower your Word Press site becomes. You can still have images and other media on your site and simply compress the content or have them hosted else where.

To host images on another server you can use an image hosting service. There are many of them out there. Below is a list of a few.

Now many of the hosting services I provided above will generate your image code for you to place into your Word Press posts. But if they don’t provide the code or if you need to adjust it, this is fairly simple.

<img src="http://server.com/location/of/image.jpg" alt="name of image" />

So if I where using Facebook for example. I would first upload the image to Facebook, set the image to be publically visible. Then I would click the image, then right click on the image and choose View Image. In the address bar I will see the URL of the image. And that is where I would place the code. For example.

<img src="https://scontent-dft4-3.xx.fbcdn.net/v/t1.0-9/XXXXXX_YYYYYYYYYYY_ZZZZZZZZZZZZZ_n.jpg?oh=ssssssssssssssssssss&amp;oe=NNNNNNN" alt="Name of Image" />

If you want to compress images then I recommend using the ShortPixel Image optimizer plugin for Word Press.

Short Pixel Image

If your media file is a Video you can use some of the following video hosting services.

Update All Posts

Lets say you have content on multiple posts that needs to be updated. We will say it is a link that is no longer available. Instead of manually going threw every post and looking for the link, you can use MySQL to search for the link and replace it all in a single command.

UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://oldlink.com', 'http://newlink.com');

If you like my work and don’t want to see ads help me fund this blog by becoming a Patron