Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Alex M.10,351 Points
Hi all - I recently moved on to the Genesis Theme Development course after getting up to speed wit the two recommended courses (Genesis Foundations and Modern WP Workflow).
Question - around the 3:40 mark, Jesse starts renaming/replacing all the functions named "centric" to "hueman." I get that he's changing the word to match his theme name, but how does he land on that word alone (is he registering that somewhere else beforehand?)? Can you use more than one word there, or are you limited to choosing a one-word title when you replacing the function names?
Brian Hayes20,986 Points
No, this name isnt exactly registered anywhere. This is a called "adding a prefix" to the function. The entire idea behind this is to prefix all of your functions so that they cannot possibly interfere with another function that may end up sharing the same name, either in WordPress core, or in a plugin.
He called the theme "hueman" and so he chose to prefix all of his functions as such.
For example if I were to want to create a function called
get_header_image() and use it in my theme called "mytheme" then the function i would actually create would be called
Prefixing functions is super common with WordPress development, and very effective as well for making sure no function shares the same name on accident, as this would cause a fatal error when the php compiles.
At the end of the day, you can name you function anything you want since its what the function does that actually matters. The only real requirements are that no two fucntions share the same name (functions inside different php classes aside), and only underscores can be used for name-spacing.
Even with this freedom, by trying to use names that make sense for the function's purpose, and adding a prefix, we are able to better remember the name when we want to call it, and keep it from matching functions from other developers.