Hi @bigfootnetworks
You can put that code in your functions.php file in your theme. But if you have a child theme, that would be better. Also, please take a look at this page to learn more about WordPress post object: https://codex.wordpress.org/Class_Reference/WP_Post.
I hope this helps 🙂