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 need to know solutions for the question above. There are cases, when we need post meta information outside the loop. Let's say, I'm developing theme that will display ads from certain vendor on that page (everywhere on that particular page) based on post meta information. Because, I've bilingual blog and I will use different vendor for each language (for CTR reason).

So, do you guys have a solutions for this kind of problem?

share|improve this question
up vote 1 down vote accepted

Do you mean meta like in custom fields or information from post in general?

Basically as long as you have post id you can get anything you want, not tied to the Loop.

For custom fields there is get_post_meta().

For general information (like title or content) there is number of functions (many template tags can be explicitly passed post id, they just default to current Loop item) and there is get_post_field($field, $post); (can't find in documentation, but self-explaining).

share|improve this answer

The global variable $post contains all the post details, so that you can use them outside the loop. Basically, you can do:

global $post;
echo get_post_meta($post->ID, 'my-ad', true);
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.