At the core of any WordPress theme, there is a file named functions.php and themes created with Pinegrow are no exceptions.
Customizing functions.php is one way to change the default behaviors of WordPress. The functions file behaves like a WordPress Plugin, adding features and functionality to a WordPress site.
You can use it to call functions, both PHP and built-in WordPress, and to define your own functions.
The functions.php file is stored with each Theme in the Theme’s subdirectory in wp-content/themes. It Executes only when in the currently activated theme’s directory and applies only to that theme. If the Theme is changed, the functionality is lost.
functions.php can have numerous blocks of code used for many different purposes.
On the web, you will find a LOT of resources with WordPress code snippets and most of them are meant to be added directly to functions.php
Adding code snippets
Once your theme is exported from Pinegrow, go to wp-content/themes/your_theme and locate the file functions.php
UPDATE: Since Pinegrow 4.9, the process is a bit different and the first time you export your theme, you receive the following warning message:
Functions.php in the source folder
File functions.php was copied to your theme source folder < the folder where you have your HTML source files
/FOLDER WHERE YOU STORE THE SOURCE/
You can add custom PHP code to this file. Just make sure not to edit any code inside ‘Code generated by Pinegrow” sections.
When you export the theme, functions.php will be copied to the exported theme folder.
As Pinegrow does not offer (yet) a way to edit functions.php directly, you have to edit the file “by hand” with your favorite text editor (try atom, its cross-platform, free and very powerful)
Our recommendation is to add all the extra code snippets at the bottom of the file, on top of the PHP closing tag (?>).
DO NOT put your snippets inside of Pinegrow reserved areas or your changes will be deleted at the next theme export.
In the following example, we have added 3 codes snippets to functions.php:
- The first snippet defines the theme content Width (useful if you use Jetpack galleries for example)
- The second snippet allows the use of shortcodes in a text widget
- The third one allows the use of excerpts in PAGES
Et voila! Once your code snippets are added, you can save your file and check the result.
Last updated on October 31, 2018 at 10:12 am