Title: Adding the start option to loop
Last modified: August 22, 2016

---

# Adding the start option to loop

 *  Resolved [gpalowitch](https://wordpress.org/support/users/gpalowitch/)
 * (@gpalowitch)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/adding-the-start-option-to-loop/)
 * Hi Eliot,
 * Sorry for all the requests and questions. This is my last request for a while.
 * I was hoping you could add the start option to the loop shortcode.
 * Thanks,
    Garrett
 * [https://wordpress.org/plugins/custom-content-shortcode/](https://wordpress.org/plugins/custom-content-shortcode/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/adding-the-start-option-to-loop/#post-5350568)
 * I looked into adding this option. The [loop] shortcode uses WP_Query to get posts,
   and there doesn’t seem to be a way to get posts by beginning characters of field
   value. So, I think the solution is to use a combination of [loop] and [if].
 *  Thread Starter [gpalowitch](https://wordpress.org/support/users/gpalowitch/)
 * (@gpalowitch)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/adding-the-start-option-to-loop/#post-5350591)
 * Basically what I wanted to do was have the posts filtered by the loop so that
   i could use the [if empty] shortcode to see if the result was empty. Maybe there
   is a way to do this already and I am just not finding it.
 * After looking at the WP_Query documentation page I have two ideas about how to
   possibly get the desired result.
 * First, it appears that you can compare strings to the another string using the
   following operators.
 * ‘=’, ‘!=’, ‘>’, ‘>=’, ‘<‘, ‘<=’, ‘LIKE’, ‘NOT LIKE’, ‘IN’, ‘NOT IN’, ‘BETWEEN’,‘
   NOT BETWEEN’, ‘EXISTS’.
 * Additionally, a relation can be added so that two operators can work together.
   I believe the use of an >= operator and a < operator would allow this to work.
   >=M and <N would give all strings that start with M. You could allow people to
   select the beginning and end values.
 * Alternatively, the results of the query could be retrieved and then filtered 
   using a function in Custom Content Shortcode before returning the results.
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/adding-the-start-option-to-loop/#post-5350600)
 * I see, I was consulting the same section in the codex, thinking of how to query
   the beginning of a field value. The _compare_ and _relation_ parameters for [
   loop] will pass the same operators to WP_Query, so you could experiment with 
   them.
 * Your second suggestion seems more straight-forward, to filter the query results
   inside CCS. OK, I’ll look at implementing this in the next update.
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/adding-the-start-option-to-loop/#post-5350665)
 * OK, I added the _start_ parameter to the loop shortcode. As per your second suggestion,
   it will filter the posts by checking the beginning of field value:
 *     ```
       [loop type="product" field="title" start="A"]
       ```
   
 * For the field, you can use predefined field names or custom field.
 * I’m just curious, how do you plan to use this?
 *  Thread Starter [gpalowitch](https://wordpress.org/support/users/gpalowitch/)
 * (@gpalowitch)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/adding-the-start-option-to-loop/#post-5350680)
 * Thanks very much for adding it.
 * I am working on a site for a homeowners association and creating a directory 
   of residents. I am using an alphabetical listing by last name and wanted a way
   to add some text if no residents with a last name that starts with a particular
   letter exist. By adding the filtering to the loop I can use the [if empty] shortcode
   to determine if the result is empty.
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/adding-the-start-option-to-loop/#post-5350683)
 * I see! That makes sense why you needed the first letter of a field, to use for
   a directory listing. Thanks for sharing, it’s always interesting to hear the 
   different ways the plugin is being used.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Adding the start option to loop’ 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/)

 * 6 replies
 * 2 participants
 * Last reply from: [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/adding-the-start-option-to-loop/#post-5350683)
 * Status: resolved