Custom Fields
Re-Envisioned
Support Meta Box Conditional Logic Show A Specific Tab When A Feature Image is Added

This topic contains 15 replies, has 2 voices, and was last updated by  Anh Tran 1 year, 3 months ago.

  • Creator
    Topic
  • #8096
    Resolved
    tsquez
    Participant

    HI there,

    I am using meta-box-tab as well as meta-box-conditional-logic extensions. In my theme the user can select where the Featured Image of a post or page is displayed. Here is the code I am added to the theme:

    https://ghostbin.com/paste/daepa

    As you can see the user has two options: they can show the featured image below the title or display it above the title.

    My question is how can I hide the Featured Image Options tab if there is no featured image and show the Featured Image Options tab if a featured image is used?

    Thanks for any help you can provide.

Viewing 10 replies - 1 through 10 (of 15 total)
  • Author
    Replies
  • #8110

    Anh Tran
    Keymaster

    Hi Thomas,

    Let me see if I can find a workaround for this.

    #8117

    tsquez
    Participant

    Awesome sir thank you. I appreciate any help.

    #8130

    Anh Tran
    Keymaster

    Hi Thomas, I’ve just updated the plugin, adding support for Featured Image. Please see the documentation for usage.

    Cheers

    #8136

    tsquez
    Participant

    Oh wow, unexpected. Thank you sir. I will take a look at it later today and let you know what I think.

    Again, thank you for the update.

    #8137

    tsquez
    Participant

    So if I am trying to HIDE the Featured Image Options TAB, where would I add the code from https://docs.metabox.io/extensions/meta-box-conditional-logic/#featured-image in the following:

    https://ghostbin.com/paste/pss7p

    I have tried adding it to Featured Image Options tab but it still shows.

    What am I doing wrong?

    P.S. yes i updated the conditional extension.

    #8142

    Anh Tran
    Keymaster

    Hi Thomas,

    Your case is a combination of the featured image rule with this tutorial.

    I added the solution to the library. Please take a look.

    (Note: I removed all textdomain and prefix to help others see the code clear).

    #8143

    tsquez
    Participant

    Hi there,

    Ah OK I see it now…lol! Thank you very much, greatly appreciated my friend.

    #8147

    tsquez
    Participant

    OK just wanted to stop in and say THANK YOU, THANK YOU, THANK YOU!!! This works beautimously…lol!

    Great job guys, you killed it. Seriously, this is AWESOME!!! Thanks again.

    #8149

    tsquez
    Participant

    Like I said before it works perfect, but I do have a question and I am hoping you can provide me with an answer as I am sure someone else will probably ask this.

    OK so before I add my featured image, this is what the metabox looks like:

    https://imgur.com/OR5CWv9 (screenshot 1)

    and when I add my featured image it looks like this:

    https://imgur.com/gNK9URW (screenshot 2)

    This is pretty cool, however, I am wondering, how can I make the “Hide Post/Page Elements” tab be the “active” tab and show the contents of that tab if there is NO featured image.

    In other words: If there is NO featured Image, how can I make it look like this:

    https://imgur.com/f0Ny2ur (screenshot 3)

    when there is no featured image I would like the next tab to be the active tab and show the tab content. Is this possible?

    I hope there is a way to do it. Thanks again guys.

    #8177

    Anh Tran
    Keymaster

    I got it. The first tab is always the active one when page loads. It’s styled by a CSS class. I think the best solution for this issue is reorder the tabs, e.g. move another tab to the top, so when Featured Image tab is hidden, the first tab is still the active one.

Viewing 10 replies - 1 through 10 (of 15 total)

You must be logged in to reply to this topic.