WordPress code snippets
Thank you for passing by on my website – this website section is dedicated to all WordPress lovers like myself 🙂
You can find in this website section over 50 WordPress code snippets, I have also tutorials, plugins, themes and because WordPress alone would never work by it self I also cover a few topics about servers and WordPress work-flow (control version github, deploy, gulp, WordPress Coding Standards).
What is a WordPress code snippets ?
In the WordPress world everyone knows that plugins can be used to extend the functionality of WordPress. But what if we can do some smaller things in WordPress without installing plugins? Lets say, we dislike the admin bar at the top and we wish to disable it. Wet can accomplished that by using WordPress code snippet.
Basically, WordPress code snippets are used to do certain actions that might otherwise require a dedicated smaller plugin. Furthermore, such code snippets are placed in one of the WordPress core or theme files (generally the functions.php file of your theme).
- Add functionality are commonly added to the theme functions.php file.
- Change functionality are sometimes added to a specific theme file e.g. single.php, page.php, search.php etc.
- Change core WordPress functionality are usually added to the wp-config.php file that is located in the root of your WordPress installation
I hope you enjoy the website and all the code available for you to use and please fell free to share your own code.
Some words of warning before you go ahead adding WordPress code snippets on your theme
- Before we start to add code to our WordPress theme always back up your site before making any changes to the code. We could end up with a plugin incompatibility. Even if you are 100% sure of something it is always worth taking precautions.
- Leland has some good advice for theme developers who are using code snippets in their themes. / If you have two functions with the same name in your theme then it’s not going to work and you’re going to spend hours trying to figure out what the problem is. If you’re planning on using any of these snippets in themes or plugins that you’re going to create and release then you should consider renaming the functions to something individual to prevent problems later. You don’t want to end up with a whole bunch of angry emails. You’ll notice that some of the functions already have very distinctive names. You can read Andrew Nacin’s blog for more on this.