WordPress.org

Forums

Advanced Custom Fields
Filter results according to subfield value (1 post)

  1. polyfade
    Member
    Posted 12 months ago #

    This repeater field is being called from another page with ID of 8.
    This repeater field is called: 'location'
    Within it I have several subfields like:'name', 'city' and 'phone'.

    I want to display any results where 'city' matches value of 'denver'

    Would this be considered a filter or conditional?

    This seems like it should be simple, but very confusing to me…
    Any help or direction is much appreciated!

    `
    // The following displays all

    <?php $other_page = 8; ?>

    <?php
    if( have_rows('location', $other_page2) ): ?>

    <?php while( have_rows('location', $other_page) ): the_row(); ?>

    <h4><?php the_sub_field('name'); ?> (<?php the_sub_field('city'); ?>)</h4>

    <p><strong>Phone:</strong> <?php the_sub_field('phone'); ?> <br>
    <strong>Fax:</strong> <?php the_sub_field('fax'); ?> </p>

    <?php endwhile; ?>
    <?php endif; ?>
    `

    https://wordpress.org/plugins/advanced-custom-fields/

Reply

You must log in to post.

About this Plugin

  • Advanced Custom Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic