Conditional Logic to display meta box based on custom post type sub categories

Support MB Conditional Logic Conditional Logic to display meta box based on custom post type sub categoriesResolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #4158
    azientarazientar
    Participant

    Hi I am using Builder to create meta boxes. I'm having trouble hiding the metabox on certain pages based on 1) It being a custom post type, 'ait-items', and also a custom taxonomy that is like categories. The ait-items custom post type has 'Investing' and 'Financial Adviser' primary and sub categories among others.

    How can I use Builder + Conditional Logic to only show the Metabox when the custom post is tagged as Financial Adviser?

    Thanks in advance.

    #4160
    Tan NguyenTan Nguyen
    Participant

    Dear azientar,

    With conditional logic for Meta Box, you can define with code like so:

    
    'visible' => [
        'relation' => 'and'
        'when' => [
            ['post_type', 'ait-items'],
            ['slug:post_category', 'Financial Adviser']
        ]
    ]
    

    So, in your MB Builder, go to Settings tab:

    - Under Conditional Logic section, select Visible when All...
    - Add a conditional logic, when field post_type is = ait-item
    - Add another conditional logic, when slug:post_category is = Finalcial Adviser

    Best regards,

    Tan

    #4168
    azientarazientar
    Participant

    Hi Tan,

    This did not work and I tried a few variations. With your suggestions, the box did re-appear on the intended post type and category, but it reappeared for all categories even if not selected.

    Adam

    #4201
    azientarazientar
    Participant

    Bumping this when you get a chance.

    #4269
    Tan NguyenTan Nguyen
    Participant

    Dear azientar,

    Sorry for the long silence, I've been sick recently. I've checked with my local development and it works properly. I'd suggest you remove the Post Type in Conditional Logic section and set Post Type in General section instead, like this screenshot:

    http://prntscr.com/cs7i12

    Can you please make sure your taxonomy is post_category and recheck your slug?

    Best regards,

    Tan

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Conditional Logic to display meta box based on custom post type sub categories’ is closed to new replies.