[wp-hackers] wordpress function naming convention

Haluk Karamete halukkaramete at gmail.com
Thu Feb 21 23:56:48 UTC 2013


your info helps.

but for example, when you look at the "wp_list_categories" example, it
definitely qualifies as a template_tag, but yet, it still starts with
wp_
it could perfectly be front-facing as the other template tags which
tend to be more popular.

This makes me think...

Could the wisdom be that if the template tag in subject is designed to
be used within "the loop", then it should start with prefix "the_" and
otherwise, it should start with the prefix "wp_"?
Could that be the key in understanding the convention?






On Thu, Feb 21, 2013 at 3:11 PM, Drew <xoodrew at gmail.com> wrote:
> In my experience:
>
>    - the_X() - These are called "Template Tags". Generally, they echo a
>    formatted version of their "get_the_X" counterpart, though there are
>    several exceptions to this.
>    - get_the_X() - Returns something (usually used by Template Tags)
>    - wp_the_X() - Basically the same as the_X() but not as front-facing as
>    Template Tags. They *are* public functions though
>    - wp_get_the_X() - Returns something (usually used by wp_the_X()
>    functions)
>    - _X() - Private functions for use by WordPress core only.
>
> Anybody else, CMIIW.
>
>
> On Thu, Feb 21, 2013 at 2:56 PM, Haluk Karamete <halukkaramete at gmail.com>wrote:
>
>> Could someone guide as to what the convention is when we see a
>> wordpress function which starts with one of these
>>
>> the_X()
>>
>> get_the_X()
>>
>> wp_the_X()
>>
>> wp_get_the_X()
>>
>> and very rarely some core functions start with _.
>>
>> as to the template tags, the convention is easy to understand, the_X
>> outputs the X inline, whereas get_the_X returns the value.
>>
>> But for all the rest, not too sure.
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
>
> --
> -- I've kinda got a thing for WordPress > http://www.drewapicture.com
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list