Title: IF statement
Last modified: November 1, 2017

---

# IF statement

 *  Resolved [l.kovich](https://wordpress.org/support/users/lkovich/)
 * (@lkovich)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/if-statement-10/)
 * Hello,
    I am managing auto dealer inventory and would like to filter cars by 
   stock number, however some of the have the same/duplicate letters like: P405112,
   B8006P
 * How do I filter it and display only cars with a stock number starts with a letter‘
   P’?
    My shortcode is below:
 * [IF({stocknumber[contains(.,’P’)]})]…[ELSE][ENDIF]
 * Thanks 🙂

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

 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/if-statement-10/#post-9652990)
 * Hi [@lkovich](https://wordpress.org/support/users/lkovich/)
 * You can use the “starts-with” function like so:
 * `[IF({stocknumber[starts-with(string(),"P")]})]Stock number: {stocknumber[1]}[
   ELSE][ENDIF]`
 * If you’re trying to do this in an [XPath filter](http://www.wpallimport.com/documentation/advanced/filtering-with-xpath/),
   it would look something like this:
 * `/node[stocknumber[starts-with(string(),"P")]]`
 *  Thread Starter [l.kovich](https://wordpress.org/support/users/lkovich/)
 * (@lkovich)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/if-statement-10/#post-9659412)
 * Worked perfectly. Thanks 🙂

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

The topic ‘IF statement’ is closed to new replies.

 * ![](https://ps.w.org/wp-all-import/assets/icon-256x256.png?rev=2570179)
 * [WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets](https://wordpress.org/plugins/wp-all-import/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-all-import/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-all-import/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-all-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-all-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-all-import/reviews/)

## Tags

 * [examples](https://wordpress.org/support/topic-tag/examples/)

 * 2 replies
 * 2 participants
 * Last reply from: [l.kovich](https://wordpress.org/support/users/lkovich/)
 * Last activity: [8 years, 8 months ago](https://wordpress.org/support/topic/if-statement-10/#post-9659412)
 * Status: resolved