Support

Account

Home Forums ACF PRO Filter a list by sub field

Helping

Filter a list by sub field

  • I’m using the following code to show a simple list of documents.

    <ul>
    <?php while ( have_rows('document') ) : the_row();?>
        <li>
            <a>" target="_blank"><?php the_sub_field('document_title'); ?>
            <small>Date published: <?php the_sub_field('date_published'); ?> Date deprecated: <?php the_sub_field('date_deprecated'); ?> Status: <?php the_sub_field('status'); ?></small></a>
        </li>
    <?php endwhile; ?>
    </ul>

    I want to use the status sub field to split the list into two separate lists the first list showing items with a status of current and the second with a status of deprecated. If there are none, then the list shouldn’t appear at all.

    How would I go about this?

  • I have realised I cantackle this another way. Instead of giving users a radio to select the status I can set up 2 separate lists that they fill with repeating content.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.