WORDPRESS CODE & IMAGES

For some time now i have been building up many snippets within “Sublime Text” that i use on a day to day basis whether its for wordpress or else most of the snippets can be used time and time again. So i thought i would share some of the most useful pieces of code for any wordpress install you should us:

1. The configuration file for wordpress
When you first setup your wordpress website, there are a few items you should update on your config file, being:
– Authentication key wordpress
– Setting up your home and siteurls
– Defining other key features of wordpress, such as autosaving, revisions (which trust me is really handy for any client), debug and more.

Here is the default code i use on a day to day basis for any client (i’ve created this into a snippet for easy access, preventing myself having to recode this each day):
define(‘WP_POST_REVISIONS’, 10 );
define(‘AUTOSAVE_INTERVAL’, 60);
define(‘EMPTY_TRASH_DAYS’, 7);
define(‘WP_ALLOW_REPAIR’, true);
define(‘WP_HTTP_BLOCK_EXTERNAL’, false);
define(‘WP_DEBUG’, true);
define(‘WP_MEMORY_LIMIT’, ‘256M’);
define(‘WP_HOME’,’http://example.com’);
define(‘WP_SITEURL’,’http://example.com’);

3. Don’t downgrade your images on upload to wordpress
So many developer out there might know WordPress doesn’t use 100% quality for your images, as it saves on space? So that’s great and all for loading time, but i’ve come across many websites that require nothing less than 100% quality to show off their high-end products. So here is a very easy fix, just open up your functions file and whack this code below in your file:

5. Useful code i have saved as a snippet
I regularly are in need of creating an if statement for pages on wordpress, whether its a template we are using for multiple pages on the website but only want to show a certain item on one of the pages. So instead of going to the wordpress library every time we have created a useful snippet which we can pull in every time to display something like:

or you might need to output a post type query and don’t have the code to hand, we created this simple snippet:

We also find every website includes buttons for pushing them important clients to the correct places, now do you find that them buttons when press always show that ever annoying blue glow around the buttons, for this reason we again created a useful snippet we use every time for all website, hope this would be useful for yourself:
input:focus
{
outline:none;
}

We also have created many snippets with “Sublime text” that we use all the time including for plugins such as ACF (Advanced custom fields) which is really useful for any developer.

6. Making sure your websites to the highest quality
Time and time again i come across websites online that have been designed and developed never to the best quality they can be, so from experience i have found to be very useful are:
– Upload imagery for your website 1.5x bigger than you need.
– Upload icons on 2x the size of the icon, so the icons are retina for all devices.

Having high quality images can reduce your websites loading speed, but making sure you save the image for web and us some useful tools such as https://imagecompressor.com/ can help you reduce the images and not loose that all important quality.

For icons, being there pretty much small touches on your website that help the design, if you don’t have these icons to hand, double the size of what you need, i would highly suggest using a website like https://fontawesome.com/ which allows you to download the icons and use as code in your website (pretty simple to install). This then gives you that ever important quality aspect in your website design.