WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to check if post meta key exists or not, out side of the loop. Is there any WordPress function to check if post meta key exist or not in WordPress database. I have to check this outside the loop. Any help will be highly appreciated.

share|improve this question
possible duplicate of Strategy to get post meta for use outside the loop – Brian Fegter Jul 25 '12 at 10:03

You could use get_post_custom(POST ID GOES HERE) which will return a multidimensional array with all custom fields of a particular post or page.

So something like:

$meta_data = get_post_custom(785);
if ($meta_data['my_meta_key'][0] != "")

would allow you check if a particular meta_key was empty or not.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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