Is there some guideline or rationale behind why some WP code functions are prefixed with wp_ ? eg: wp_insert_post() vs. update_post_meta()


4 Answers 4


This makes not that impressive answer, but - none.

get_ is suffix usually means function returns something, the_ that function echoes something.

wp_ doesn't carry technical meaning and inconsistency in naming is from many developers participating and lack of movement to unify (moving forward is considered more important than major cleanups of older stuff to make it neat).

  • 1
    I (somewhat) understand the reasoning for not remedying the current situation; however, I am puzzled by the lack of defining some point in time from which, henceforth, a defined function nomenclature would be enforced. Wishful thinking, I suppose. Aug 24, 2011 at 13:03
  • Thanks Rarst. Otto confirmed it. Sigh. I was hoping... I'm with Chip!
    – Tom Auger
    Aug 24, 2011 at 19:02

Wordpress was and is written by a lot of different people. Patches are discussed inside wordpress trac and whoever submits or assigns to a trac ticket can post patches. If the patch gets accepted and moved into core of an upcoming version it's simply in there. So sometimes functions, vars, etc. gets the prefix while other times they don't. It relies on the participating developers.


The wp_ prefix is usually added to avoid naming conflicts with:

  • native PHP functions, such as get_current_user()
  • older/deprecated WP functions, such as get_archives()
  • third-party libraries?

I always assumed the distinction was that - beyond the basic template tags, which generally just have the simplest descriptive name possible:

  1. functions that begin with wp_ are generally high-level public API functions, which are pretty much guaranteed to always be around and retain forwards-compatability.
  2. functions without that prefix are internals, stuff you shouldn't muck around with unless you know what you're doing.

I don't know if this was ever intentional, though. And like the other two answers have said, it doesn't hold up consistently. Your example of update_post_meta is a perfect example of something that seems like it should should have a wp_ prefix if my classification held true. But there's enough deep legacy code in WordPress to throw off any attempt at making sense of any naming convention.

  • haha. I actually thought it was exactly the opposite - that wp_ functions were more of the internal (you-can-use-it-but-it's-really-internal) variety while the others were more public. Sad as it sounds though, maybe Rarst et al. are right and there is no rationale.
    – Tom Auger
    Aug 24, 2011 at 12:29
  • 3
    For the record the really internal functions start with underscore alone _* But there aren't that many of those and in practice they aren't that absolutely internal-only either.
    – Rarst
    Aug 24, 2011 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.