Latest From The Blog

This tool makes setting up WordPress locally 10x faster!

This tool makes setting up WordPress locally 10x faster!

I’m sure you’ll agree that it is important to build and work on sites in a staged environment before putting them live. Even though we don’t always follow this advice (quick fixes don’t always warrant the effort of syncing to a local environment), it is an important habit to adopt.

The only problem here is that it is time-consuming. It’s not going to take hours but, it takes enough time to be an inconvenience.

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

I’m always on the lookout for new tools to speed up my workflow. For example, when migrating sites, I use duplicator as it makes the process smoother and quicker. So, when it comes to building a new website locally, I have a powerful tool that makes the process a breeze.

I prefer to do as much of my work as possible from the command line. There’s a lot less reaching for the mouse that way. It just so happens that there is a tool that mashes WordPress and the command line together. WP-CLI (WordPress Command Line Interface). There are so many jobs you can do using this helpful tool. What I’m going to show you today, is how to install WordPress locally using this tool.

 

Installing WP-CLI

I’m going to throw you over to the official docs for this one. Head over and get it installed on your machine (I recommend taking a look at getting autocomplete setup too, as this will save you a lot of time in the long run.

 
 

Make a folder for your new site

I’m going to assume you know at least a little bit about command-line while doing this (fire a comment below if you need me to clarify any of the commands). We need to make a new folder for our new WordPress install. I use a Mac therefore, I use MAMP to serve my WordPress sites locally. If you are using windows check out WAMP.  We need to go to the folder that MAMP uses to store websites. By default, it is located in:

/Applications/MAMP/htdocs/

unless you have explicitly changed it. Change it to that directory

cd /Applications/MAMP/htdocs/

Next, we need to create a new folder.

mkdir /Applications/MAMP/htdocs/nameofwebsite

Then move into the newly created directory.

cd /Applications/MAMP/htdocs/nameofwebsite

Now the fun begins.

 

Download WordPress in a flash

This is the easiest part by far. Type the command below into your terminal (or copy and paste, your choice).

wp core download

Before your eyes, you will see WordPress installing into your newly created directory.

 

Create the config file and database.

The next step is to create you wp config file

wp config create --dbname="name of your database" --dbuser="root" --dbpass="root"

You can call your database whatever you’d like. It doesn’t exist yet. Let’s create it

wp db create

You have now created a WordPress database in seconds. No stuffing around with MySQL or phpmyadmin required.

 

The famous 5 minute install done in less than a minute!

Now we have to install WordPress. I often forget parts of this one but here is a little tip I picked up. By typing wp core install  you will receive an error message. However, contained in that error message are all the missing parameters you will need.

wp core install --title="Name of your site" --url="path to your site" --admin_user="user" --admin_password="password" --admin_email="email@address.com"

 
 
 
 
 

Congratulations, you have now installed a new WordPress website locally. It only took 4 commands total. Pretty neat huh!

WP CLI is an amazing tool with a heap of different functions that it can perform. If you do nothing with it other than installing WordPress sites locally it is worth the effort to install it alone. I challenge you to delve a bit deeper and find out what else you can do with this tool. Leave a comment below and tell me what you discover. I will be writing a lot more about WP CLI in the future, so stay tuned for more tricks.

 
How to get your JavaScript files working in the WordPress backend

How to get your JavaScript files working in the WordPress backend

I’m sure you have had that moment where you are at a complete loss as to why something isn’t working (not to mention the annoyance that you know that the answer is going to be stupidly simple). You have tried absolutely everything and ran through the process step by step but still, it’s not working.
Well, I had this particular moment when trying to write some JavaScript for the backend of a plugin we were building. No matter what I did it would respond. No console.logs, no alerts, nada!!
Turns out that enqueuing for the backend has a subtle difference to enqueuing for the front end.

Enqueuing On the Front End

function custom_script(){
wp_enqueue_script('My Custom Script', plugins_url( 'js/custom.js', __FILE__ ), array());}
add_action('wp_enqueue_scripts', 'custom_scripts');

Enqueing On The Back End

function custom_script(){
wp_enqueue_script('My Custom Script', plugins_url( 'js/custom.js', __FILE__ ), array());}
add_action('admin_enqueue_scripts', 'custom_scripts');

The only difference is in the last line. Use admin_enqueue_scirpts instead of wp_enqueue_scripts.
Happy coding folks!!

Move your WordPress website to another host with less anxiety!

Move your WordPress website to another host with less anxiety!

As web developers, we can often get stubborn about the right way of doing things (of course the right way is always our way). Site migration can be one of those. The manual way is often the prefered method as you have full control and you know that everything is backed up. Today it is my mission to get you to change your ways.
For site migration of WordPress sites, I use a plugin! Before you all look down on me, let me explain why. I have moved plenty of sites around the manual way. Sometimes this was for clients moving there site to our hosting and sometimes it was going from a staging site to a live site (or vice versa). I’ve done the search and replace of the sites URL in the site’s database countless times. Its easy enough to do all this but for some reason, I always feel a little nervous about it. So, I decided to try out Duplicator and I would never go back.
As soon as duplicator is installed and activated on the site you want to migrate, you head over to the admin section and click the create package button. From there you are given options to filter out any files you don’t want to move over (think subdomains and addon domains), you are given the option to enter in the name of the new database and host so that you don’t need to fill it in later. It then does a check to see if everything looks good. This is where there may be a downfall for some of you (this can be fixed by purchasing the pro version), if your site is over 250mb then you will be warned that the package may not be able to be created. It will check the database. If all looks good it will create a zip file containing your whole site + your database and a hand installer file to download.
The next step is to move the file you just downloaded into their new destination. Once you have moved or uploaded the files to where you want to have your site, you simply need to go to the site in your browser with installer.php tacked on to the end.
http://your-site.com/installer.php
http://localhost/your-site/installer.php
You are then taken through the steps to install your site. This takes a matter of seconds to complete. You will be stunned when your site is up and running exactly the way you intended (no search-replace required). You will be prompted to delete the installations files which are taken care of with the click of a button.
A few things to note.

  • It may be worth resetting the permalinks once you have the site up. This ensures every page is going where it needs to.
  • When at the database section of installation, if you use the option create new database, pressing test will return an error saying the database was unable to be reached. This is because it doesn’t yet exist. Ignore this.

So, next time you migrate a WordPress website, give duplicator a go. It will seriously speed up your workflow and take any anxiety the goes with moving websites and databases away.

What we do

Wordpress Themes & Plugins

We love using WordPress to build websites. Sometimes we have an idea of a website that needs extra functionality that isn’t built into WordPress. So we find the solution! If you don’t see anything that solves your WordPress problem, get in touch.

Software Development

We love getting stuck into new software projects. Whether it is a piece of software for a specific industry or a programme that makes everyone more productive, we are up for the challenge.

Latest Products

Follow Us On Social Media