252 posts
  • Elite Author
  • Won a Competition
  • Has been a member for 4-5 years
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Bought between 10 and 49 items
  • Referred between 50 and 99 users
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 ... );
}
436 posts Don't be a HATER!
  • Exclusive Author
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Has been a member for 4-5 years
webinpixels 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

4264 posts ThemeForest Reviewer
  • Envato Staff
  • Reviewer
  • Community Moderator
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Venezuela
  • Has been a member for 5-6 years
  • Microlancer Beta Tester
  • Sold between 10 000 and 50 000 dollars
  • Exclusive Author
+9 more
Ivor Reviewer 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
  • Beta Tester
  • Bought between 100 and 499 items
  • Elite Author
  • Europe
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 100 and 199 users
  • Sold between 100 000 and 250 000 dollars
+1 more
Themolution says

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

by
by
by
by
by
by