Support » Plugin: Custom Content Shortcode » 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

    (@miyarakira)

    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.