aw2_loop_item

This shortcode is used to access the current item being looped within aw2_loop of awesome shortcode platform. aw2_loop_item provides easy way to do check even/odd or get index value within loop.

All the attributes below are applied to main, you can also use ‘set_param’ to save the output to a variable.

attributes:

  • loop_index :
    It returns the index value of current item. By default it counts from the index from 1, but your can set start_zero=true to make the index to count from 0.
  • loop_key :
    If the item is an array of key: value pair, it return the key of the item.
  • loop_value:
    If the item is an array of key:value pair, it return value of the item.

Examples:

aw2_loop_tem also provides few quick conditionals within loop:

  • first:
    You can use ‘first’ to check if it is first item in the loop.
  • last:
    You can use ‘last’ to check if it is last item within the loop
  • even:
    You can use ‘even’ to check if it is an even count within the loop index
  • odd:
    You can use ‘odd’ to check if it is an odd count within the loop index.
  • series:
    You can use ‘series’ to check for custom index by specifying divide_by and mod parameters. In this, idex is divded by the ‘divide_by’ and result is compared with ‘mod’ if they match result is returned.
  • between:
    You can use ‘between’ to return value between two looped items.

Examples: