1141 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 100+ items on Envato Market
+2 more
KarmaThemes says

Hi everybody!

Thanks for checking out this thread. I hope you can assist me on this one:

Can I somehow create a conditional inside the metabox definition file, like this:

  1. I got a metabox asking below each post editor if this post should be added to the portfolio or not
  2. I got several advanced metaboxes like “add a slider to the item” “add a company” etc.
  3. I only want to display the advanced metaboxes of 2. if the selection of the metabox in 1. is set to yes

this is the pastie for the selection

I reckon it’s something like this? if(get_post_meta(get_the_ID(), 'portfolio_add_item', true) == 'yes') :

I did add such a conditional for the “add a slider” selection and it works in the frontend files, but it does not seem to work inside the metabox field files.

If any of you got a clue about this, please write here or contact me through our profile page, I could really use some help on this one.

Thanks a bunch! Mel for KarmaThemes

373 posts plop
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been part of the Envato Community for over 5 years
  • Made it to the Authors' Hall of Fame
+8 more
kimonothemes says

Not sure if I got your problem but do you have the var $prefix define in your metabox code? Maybe it’s because your are looking for “portfolio_add_item” but it’s named with a prefix like “themeprefix_portfolio_add_item”.

438 posts
  • Has been part of the Envato Community for over 4 years
  • Sells items exclusively on Envato Market
  • Located in United States
christopherjon says

I’m not sure how to add a metabox conditionally based on options selected in another metaboxe but I have done something similar to what your asking about in one of my themes and I used jquery to switch between stuff.

My setup is a dropdown select and depending on which option is selected different additional options are shown. The only difference is it’s all in the same metabox.

To get you started: http://api.jquery.com/change/

The demo has most of the work done for you already.

2588 posts Put a Donk On It
  • Elite Author: Sold more than $75,000 on Envato Market
  • Sells items exclusively on Envato Market
  • Made it to the Authors' Hall of Fame
  • Has sold $250,000+ on Envato Market
+10 more
ThemeProvince says

You cannot hide wordpress meta boxes conditionally using php so you have to hack WordPress using jquery/js.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by