Title: Using [for each] with a variable list
Last modified: April 1, 2021

---

# Using [for each] with a variable list

 *  [iantresman](https://wordpress.org/support/users/iantresman/)
 * (@iantresman)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/using-for-each-with-a-variable-list/)
 *     ```
       [set numbers='400,401,402,403,404']
       [for each=numbers]
         [each]
       [/for]
       ```
   
 * I was hoping to display each number from the list.
    1. Have I created a list?
    2. Can this be achieved with [for]?
    3. I don’t need to use [pass] as the variable has been set?
    4. Can I use the range ~ operate to create a list like this?
    5. I assume this could also be done with [loop] too?

Viewing 1 replies (of 1 total)

 *  [polarracing](https://wordpress.org/support/users/polarracing/)
 * (@polarracing)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/using-for-each-with-a-variable-list/#post-14267789)
 * Thats not valid:
 * Try:
 *     ```
       [set numbers]400,401,402,403,404[/set]
       [pass vars]
       [-pass list={NUMBERS}]
       {-ITEM}
       [/-pass]
       [/pass]
       ```
   
 * Have I created a list? – NO
    Can this be achieved with [for]? – NO I don’t need
   to use [pass] as the variable has been set? – NO – And this does not set a list
   Can I use the range ~ operate to create a list like this? – YES I assume this
   could also be done with [loop] too? – ??
    -  This reply was modified 5 years, 2 months ago by [polarracing](https://wordpress.org/support/users/polarracing/).
    -  This reply was modified 5 years, 2 months ago by [polarracing](https://wordpress.org/support/users/polarracing/).

Viewing 1 replies (of 1 total)

The topic ‘Using [for each] with a variable list’ 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/)

 * 1 reply
 * 2 participants
 * Last reply from: [polarracing](https://wordpress.org/support/users/polarracing/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/using-for-each-with-a-variable-list/#post-14267789)
 * Status: not resolved