Code Snippets: Adding PHP Functions & Filters Without Editing Theme Functions File In WordPress

For customizing the default behavior of WordPress, webmasters either use plugins or insert hacks i.e. PHP functions and filters inside activated theme’s function.php file.

This works but when you insert any code without creating a child theme, it gets is automatically washed away in new updates.

Earlier we have discussed about creating child themes, we have also discussed about generating child theme with a user friendly wizard and there is a plugin that allows you to generate child theme of any theme in a click of a button.

Yes, you can easily insert custom PHP function in the functions.php file of your child theme but today in this lesson you will learn about a more easy way of inserting and activating PHP hacks directly from your admin area dashboard.

Code Snippets is a very useful WordPress plugin that provides you an easy, clean and simple way to add PHP code snippets to your site, removing the need to add custom snippets to your theme’s functions.php file.

Start by installing ‘Code Snippets’ plugin in WordPress

Code Snippets 2

Upon activation, visit your admin area dashboard Code Snippets -> Add New page, write or paste your PHP function, give it a title so that you can remember why you are using it on your website and click ‘Save Changes & Activate’ button.

Code Snippets 1

You can activate or deactivate snippets individually on your WordPress site. the plugin also works on WordPress multisite networks. Network admin can network activate custom PHP functions and manage them all from one admin screen.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.