WordPress Tips & Tricks for Developers

My day job at FHOKE is writing HTML, CSS, JS and PHP for WordPress themes. Sometimes we do Shopify stores, but 90% of our work is centered around WordPress.

Over the last 3 years I’ve learned a lot about how to maximise a WordPress theme, so my main goal has been to streamline the creation of new themes.

In that time I’ve developed an in-house solution we use for all our themes, we call it Slate. As a result from years of tweaking it’s now our default basic WordPress starter theme. It has all the bits we need from project to project, which is especially helpful when we’re building 3 – 4 new themes a month.

Below I’ve collected a load of snippets you can use to hopefully improve your own themes

1.) Remove Extra <br> and <p> Tags in Shortcodes

When you start making your own shortcodes, you’ll discover what a pain it can be. Mostly due to the the_content filter adding extra paragraphs and line breaks inside your shortcode which can mess up the formatting of your custom HTML, therefore you’ll need the following to fix that:

2.) Change The Excerpt Length and Text

It’s usually one of the first things you’ll do when developing a WordPress theme. Changing the default excerpt length and suffix text really helps give it that extra bit of customisation and fit better with the design you’re working to.

4.) Allow SVG Upload

WordPress doesn’t allow SVGs to be uploaded into the media library by default, therefore you may have an issue if you’ve moved on from 2x PNG icons. However with the following piece of PHP you can get the media library accepting them in no time.

function mime_types($mimes) {
$mimes[‘svg’] = ‘image/svg+xml’;

return $mimes;
}

add_filter(‘upload_mimes’, ‘mime_types’);

5.) Add Custom Post Types to The Dashboard

On the dashboard of every WordPress site there’s a widget called “At a Glance”. It shows you how many posts are listed under each of the default post types (Posts and Pages)…but would probably be better if you could add your own, right? You can also add your own CPTs to that widget like so:

6.) Change The Footer Attribution in The Admin Area

At the bottom of every WordPress admin page there’s a line of text that says “Thank you for creating with WordPress“. If you’re developing sites for clients, it’s can sometimes handy to change that text because it connects your name with both the front and back-end of the site. Here’s an example:

7.) Add a Custom Help Widget to The Dashboard

You can add a custom widget to the dashboard to help your client get in touch if they have any questions about the site you’ve built for them, consequently making them feel more valued because of the easy support: