WordPress function naming convention, what “get” and “the” mean in WordPress function names

Back to Blog

While WordPress has some inconsistencies in how it names things, some of the function names in WordPress can indicate what that function does.

“the” in a function name means that the function will work in “the” post loop. So, for example, “the_title” will output the title of the current post in the loop.

<?php the_title(); // will output the title ?>

“get” in the function name means that the function will return the value instead of outputting it. For example, “get_the_title” will return the title instead of outputting it.

<?php get_the_title(); // will not output the title ?>
<?php echo get_the_title(); //will output the title ?>

This naming convention is helpful to keep in mind when writing WordPress code snippets because it immediately indicates how a function will perform. And it might be a good idea to follow the same convention when naming your functions.

The Most Powerful Code Snippets Plugin

Save hours when customizing WordPress sites.
Manage Snippets in WordPress
Works with All Plugins
Send Snippets to the Cloud
A Better Code Editor
Conditionally Run Snippets
Works Locally, or In the Cloud

Get WPCodeBox, the most powerful WordPress Code Snippet Manager.

Save hours when customizing WordPress sites.
WPCodeBox is a WordPress Code Snippets Manager that allows you to share your WordPress Code Snippets across your sites.