Adding code to the function file

If you move the function and the add_filter function to the functions file, the you don’t need to echo the function after. If the function doesn’t involve using add_filter then you could echo out the function in your template file. Placing it in the functions.php file, will run on every page/post load unless specified otherwise.