Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer 1

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

if(is_singular('my_custom_post_type'))
//do your stuff
share|improve this answer
add comment

Your Answer

 
discard

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.