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'd like to display content from a custom meta box that appears for a particular custom post type in the sidebar, when a single post of that type is being displayed. I know how to normally display that content in the post content area, but I'm assuming that using that same code in a widget won't work, since the sidebar is outside of the loop (right?). Any suggestions?

share|improve this question
up vote 1 down vote accepted

Well, you could access the $post variable with global $post and then access it's meta values with get_post_meta($post->ID) or something close to that. If you just want that to be accessed when you are viewing a single post, you can use

//do your stuff
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.