Reads a postmeta value directly from the master database.

This is not intended for front-end usage. This purpose of this function is to avoid race conditions that could appear while the caches are primed. A good scenario where this could be used is to ensure published posts are not syndicated multiple times by checking a postmeta flag that is set on syndication.

Note: this looks complicated, but the intention was to use API functions rather than direct DB queries for upward compatibility.


Name Type Description
$post_id int The ID of the post from which you want the data.
$key string A string containing the name of the meta value you want.
$single bool Optional. If set to true then the function will return a single result as a string. If false (the default) the function returns an array.

Return Value

mixed: Value from get_post_meta

Ready to get started?

Drop us a note.

No matter where you are in the planning process, we’re happy to help, and we’re actual humans here on the other side of the form. 👋 We’re here to discuss your challenges and plans, evaluate your existing resources or a potential partner, or even make some initial recommendations. And, of course, we’re here to help any time you’re in the market for some robust WordPress awesomeness.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.