Support

Account

Home Forums ACF PRO Sort Checkbox Alphabetically

Helping

Sort Checkbox Alphabetically

    • webecho

    • November 27, 2019 at 6:40 pm

    I have checkboxes set up for Facilities at holiday houses
    I have allowed the managers to add custom values on each house.

    How do I then organise the displayed result to order alphabetically?

    i.e.

    Air-Con
    BBQ
    Beachfront
    WiFi
    Garage (added value)

    to display as

    Air-Con
    BBQ
    Beachfront
    Garage (added value)
    WiFi

    Im currently using the following code:

    <?php if( get_field('amenities_lifestyle') ): ?>
    <?php
    $items = get_field('amenities_lifestyle');
    
    if ($items): ?>
    <ul class="amenities">
    <p><strong>Facilities</strong></p>
    <?php foreach( $items as $item ): ?>
    <li><?php echo $item['label']; ?></li>
    <?php endforeach; ?>
    </ul>
    <?php endif; ?>
    <?php endif; ?>
    • Wish

    • November 27, 2019 at 7:41 pm

    Hey,
    There is a php function called sort() which is used to sort an array of values.

    $cars = array("Volvo", "BMW", "Toyota");
    sort($cars);

    Might be of some use to you.

Viewing 2 posts - 1 through 2 (of 2 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.