Title: Loop construction
Last modified: April 3, 2018

---

# Loop construction

 *  [bubba](https://wordpress.org/support/users/koberlin/)
 * (@koberlin)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/loop-construction/)
 * I have two custom post types: Stores and Products.
 * In Stores, a custom field (using Toolset Types) captures the store’s location
   address.
 * In Products, a custom field (also using Toolset Types) captures a list of multiple
   store addresses where the product is available.
 * I am attempting to create loops so that when the data matches…
 *  Store post will display related products.
 *  Product post will display related locations.
 * I know how to set up the basic loop, but not sure how to write the fields/validation.

Viewing 1 replies (of 1 total)

 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [7 years, 12 months ago](https://wordpress.org/support/topic/loop-construction/#post-10400503)
 * Hello,
 * This may be possible using `[pass]` to pass the location(s) and `[loop]` to search
   the other post type.
 * In the page for a store..
 *     ```
       [pass field=location]
       [loop type=product]
       [if field=location value={FIELD}]
       This product matches: [field title]<br>
       [/if]
       [/loop]
       [/pass]
       ```
   
 * From your description, the product’s location field is some type of repeater 
   that contains multiple values? If it’s a straight-forward PHP array of values,
   you might be able to use `[array]` shortcode to loop through each value and check
   that instead.
 *     ```
       [array field=location]
       [if field={VALUE} value={FIELD}]
       This product matches: [field title]<br>
       [/if]
       [/array]
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Loop construction’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-shortcode_766976.svg)
 * [Custom Content Shortcode](https://wordpress.org/plugins/custom-content-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-shortcode/reviews/)

## Tags

 * [field](https://wordpress.org/support/topic-tag/field/)
 * [post-type](https://wordpress.org/support/topic-tag/post-type/)
 * [values](https://wordpress.org/support/topic-tag/values/)

 * 1 reply
 * 2 participants
 * Last reply from: [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * Last activity: [7 years, 12 months ago](https://wordpress.org/support/topic/loop-construction/#post-10400503)
 * Status: not resolved