263 posts
  • Weekly Top Seller
  • Elite Author
  • Author Level 8
  • Winner
+6 more
der
says

Ivor, you can use the in_category($cat) template tag, to determine if the post is on the specific category. $cat can be either the category slug, the category name, or the category ID.

So, you can use the template tag to determine if the post being edited (since the post being created doesn’t have a category yet), has the specific category. This way you can conditionally include the post metabox, based on the category of your preference.

For example:

if ( in_category('Design')  ) {
    add_meta_box( ... args ... );
}
461 posts Don't be a HATER!
  • Weekly Top Seller
  • Elite Author
  • Author Level 8
  • Featured Author
+6 more
CodeElite
says

Sorry about my english,

How about adding checkbox or select option and place a jQuery “onchange” function to detect the value, when value = 1, then the metabox will visible..yeah old trick just simple make the metabox container hidden. :) but we must make the checkbox/select option as data too, so when people edit their post the metabox will keep hidden if the checkbox/select option value = 0. And simple add the logical function on the metabox container



<select name="_useornot">
<option selected value="0">No</option>
<option value="1">Yes</option>
</select>

<div class="metabox_cont" <?php if(get_post_meta($postID, '_useornot', true) == 0) echo'style="display:none;"; ?>>

---metabox code



hehe, never try this..but maybe can help you :D

4483 posts ThemeForest Senior Reviewer
  • Affiliate Level 1
  • Author Level 6
  • Collector Level 3
  • Envato Team
+14 more
Ivor
Envato team
says
Ivor, you can use the in_category($cat) template tag, to determine if the post is on the specific category. $cat can be either the category slug, the category name, or the category ID.

So, you can use the template tag to determine if the post being edited (since the post being created doesn’t have a category yet), has the specific category. This way you can conditionally include the post metabox, based on the category of your preference.

For example:

if ( in_category('Design')  ) {
    add_meta_box( ... args ... );
}

Thanks a lot Der, I’ll definitely try it.

@Themesguy Thanks, I’ll give it a try :) let’s see.

72 posts
  • Elite Author
  • Winner
  • Featured Author
  • Beta Tester
+7 more
Octolooks
says

Great one, i was searching for that, thanks mate.

by
by
by
by
by
by