• Resolved newbee_sue

    (@newbee_sue)


    We are using acf for our site and would like to code one of our fields within a collapse-o-matic toggle – how can I implement collapse-o-matic within the functions.php code that I am using for acf.

    if ( !function_exists( ‘display_article’ )):
    function show_one_source() {
    the_sub_field(‘source’);
    // we would like this field in a toggle
    the_sub_field(‘translation-content’);
    // end field in a toggle
    }

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author twinpictures

    (@twinpictures)

    As we don’t like to assume, please be more detailed in your description.
    For example, what exactly are you referring to by afc? We assume you mean Advanced Custom Fields and not the Asian Football Confederation, but best to clear that up with a link, don’t you think?

    As for your code, does the function:

    the_sub_field(‘translation-content’);
    

    it looks like this function will echo the translation-content.
    is there a version of this function that will return the value as a variable?

    What did you want to use as your trigger text?

    You might want to looked into using the roll-your-own method, as it allows for more flexibility when using inside of functions.

    Thread Starter newbee_sue

    (@newbee_sue)

    (; yes – it is advanced custom fields advancedcustomfields.com –

    thank you!
    i don’t think there is a function that will return the value as a variable. why is this sugnificant?

    the trigger text should be ‘translation’

    Plugin Author twinpictures

    (@twinpictures)

    You will need to have a unique ID for each element, so if you can pass an ID that would be optimal:

    
    $my_id = <pass your id here>;
    echo '<div class="collapseomatic" id="expand_'.$my_id.'" title="Translate">Translate</div>';
    echo '<div id="target-my_id" class="collapseomatic_content ">';
    the_sub_field(‘translation-content’);
    echo '</div>;
    

    If you need more personalized assistance, you might want to consider upgrading to collapse-pro-matic, as it has a very high level of personalized support.

    Thread Starter newbee_sue

    (@newbee_sue)

    great – will try out your suggestion and look into the upgrade

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘using collapse-o-matic with acf’ is closed to new replies.