Support

Account

Home Forums Feature Requests Conditional Logic using Taxonomy field

Solving

Conditional Logic using Taxonomy field

    • newaira

    • February 18, 2018 at 1:07 pm

    I’ve needed this as well, so I created a custom field setting which allows for conditional logic based on taxonomy. Give it a try when you get a chance.
    https://github.com/andrejpavlovic/acf-conditional-logic-advanced

    ACF Conditional Logic Advanced

  • YES!!!!!!!!!!!!
    I am SO looking forward to this!!

    • Smitxv

    • February 24, 2019 at 7:05 am

    Hi guys!
    Is there any news about conditional logic by taxonomy terms?

    • Beee

    • February 24, 2019 at 7:08 am

    LOL @ smitxv : did you actually bother to read the topic ? There are 2 custom solutions in this topic and 1 native…

    • Smitxv

    • February 24, 2019 at 1:20 pm

    Bee, I’v found two solutions:
    1) Plugin: Condition logic advanced: it works with taxonomy selected in WP (tight section) – not acf field
    2) Nativ: first field taxonomy term(radio button) and we can select ONE term, then logic – if term id is > and <
    But if AFC fiel is multiple selected fied it returns array of terms, what solution?
    Thanks!

    • Beee

    • February 24, 2019 at 1:22 pm

    See page 3

    • Smitxv

    • February 25, 2019 at 3:54 am

    Good evening, Beee
    Do you mean mesaage by marlonleite August 19, 2016 at 10:12 pm
    function my_acf_admin_head()… ?
    I can not implement it, there is no comments, and I don’t understand how to use it
    Or you mean another solution?

    • Smitxv

    • February 25, 2019 at 4:11 am

    Bee, I’v found plugin https://github.com/mattkeys/ACF-Conditional-Taxonomy-Rules it works with multiple select fields, it works!
    Pleace help with your code?
    I’ve chanched filed name and taxonomy name to save by wp, but it is not work, what is wrong?

    
    function change_post_taxonomy_44582( $post_id ) {
        // bail if no ACF data
        if ( empty($_POST['acf']) ) {
            return;
        }
        // get term id from $post_id (only 1 value is allowed, so it returns 1 value only)
        $stored_sex = wp_get_post_terms($post_id, 'aptype');
        // get submitted value from acf form
        $posted_sex = $_POST['acf']['acf-field_5c72c3e3cfc4d'];
        // get term_id for the submitted value
        $term_id    = get_term_by( 'name', $posted_sex, 'aptype' );
        // if stored value is not equal to posted value, then update terms
        if ( $stored_sex != $posted_sex ) {
            wp_set_object_terms( $post_id, $term_id->term_id, 'aptype' );
        }
    }
    add_action('acf/save_post', 'change_post_taxonomy_44582', 20);
    
    	
    • Beee

    • February 25, 2019 at 4:56 am

    I can’t tell what’s wrong just from this little piece of code…

    It also depends what you wanna do… Just look at the code and dissect it to fit your needs.

Viewing 10 posts - 101 through 110 (of 110 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.