WordPress add functions – safe method [ 843 views ]
Goal: add own functions to the wordpress site
Forget the functions.php! Frankly this is working only until the next update :(.
My way is to create a totally separated file with the added functions:
1. Let’s create a new file functions_added.php
<?php function fnc_001( $param, ... ) { ... } ... function fnc_nnn( $param, ... ) { ... }
Never put php close tag ?> to the end of the file!
2. Put this file into the theme main directory.
3. Link this file to the theme header.php file. Add the following to the start of the header file.
<?php require (get_template_directory() . '/' . 'functions_added.php' ); ?><!DOCTYPE html...
This is it. All my new functions are in a safe place now.
