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've been using metaboxes for a while now, and enjoyed their flexibility. However, I am now in a situation where I need the metabox to appear only for a specific single post or page, and not for the whole (custom)-post-type. Is it possible to do so?

Your kind assistance would be most welcomed.

TIA Matanya

share|improve this question
up vote 0 down vote accepted

Since you are familiar with the how to create metabox using add_meta_box already, I'll skip to the relevant bits.

You can either conditionally add_meta_box depending on the current post title, or ID, (this is the preferred method) or, you can conditionally remove_meta_box depending on the the post displayed.

To detect the current post ID you would get_query_var( 'post' ) and move on from there, using get_post(get_query_var('post')) if further post data is required to filter out the metabox.

share|improve this answer
Thank you so much for your brief yet informative answer. Best. Matanya. – Matanya Mar 13 '12 at 14:34
You're welcome. Note I changed id to post in get_query_var, just in case you find out it doesn't work. – soulseekah Mar 13 '12 at 14:37

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.