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

Ovidiu
Founder of WPCodeBox

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.

Customizing your WordPress site using 
Code Snippets is really easy.

Try WPCodeBox today. There's a 30-day money back guarantee.
Get WPCodeBox
Copyright © 2022 WPCodeBox SRL. All other trademarks are the property of their respective owners
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram