Hi Brendan, 🙂
To add php code to your site, we recommend that you use the Code Snippets plugin (https://wordpress.org/plugins/code-snippets/). If you have never activated this plugin, please read the following post:
Hope this will help you get what you’re trying to achieve.
We’re waiting for your feedback.