Shortcode Attribute Linking and Where Clause

Note: The following does not work with Advanced Inventory Manger custom fields.  This ability is for regular system fields only.

The shortcode allows you to “chain” or “link” various attributes as well.  This is very powerful.  For example, if we had a car dealership website, we could list out a specific make and model like so:

 [wpinventory make="Chevy" model="Tahoe"] 

Lets take it a step further, and add the specific year of Tahoe’s we want to display:

 [wpinventory make="Chevy" model="Tahoe" year="2017"] 

And, we can even take it a step further using the new custom “where” clause.  So, if you wanted to showcase certain Tahoes that fall under a certain price, you could do:

 [wpinventory make="Chevy" model="Tahoe" year="2017" where="price >= 20000"] 

That would tell whatever page you have that shortcode on to output the 2017 Chevy Tahoes that are greater than $20,000.00.

Lets take it another step.  Lets say you want all the 2017 Chevy Tahoes that are above $5000.00, but you only want to display them if the quantity you have on hand is above a certain amount (that way you know you never truly run out and have a few at the dealership):

 [wpinventory make="Chevy" model="Tahoe" year="2017" where="price > 5000 AND quantity >= 3"] 

That would output all 2017 Chevy Tahoes that cost $5000.00 or more and are not below the quantity of three.  Meaning there are at a minimum of three of them on the lot.

Lastly, is the absolute power of the “where” clause.  It is essentially allow you to write your own SQL queries.  If you don’t know what those are, then you may not want to attempt to use it.  It can throw an errorif the query is not correct.  So, if you do try to use the where clause, then make sure your page is loading the inventory as desired.  Now, with all that being said, the power of the “where” clause all by itself could do what we did above if we just wrote it as:

[wpinventory where="make='Chevy' AND model='Tahoe' AND year='2017' AND price > 5000 AND quantity >= 3"]

The above shortcode uses single quotes to surround the value you are checking for and it is all inside of the where clause.  There are many many things you can do with this functionality if you are knowledgeable with SQL.

Shortcode Options

Shortcode options

Here is a list of all of the core fields

You can use any of the following in the shortcode.

  • inventory_name
  • inventory_make
  • inventory_model
  • inventory_year
  • inventory_serial
  • inventory_fob
  • inventory_status
  • inventory_quantity
  • inventory_quantity_reserved
  • inventory_price
  • inventory_number
  • inventory_sort_order

  • inventory_description
  • inventory_size
  • inventory_manufacturer
  • inventory_slug
  • category_id
  • category_name
  • category_slug
  • user_id
  • hide_low
  • hide_low_quantity
  • page
  • page_size

For example:

[wpinventory inventory_make="Chevy" inventory_model="Tahoe" inventory_year="2011"]

This shortcode would show all 2011 Chevy Tahoes in the system.

The following are some possible examples to do various things

  • [wpinventory category_name="Your category name here"]

    – This shortcode attribute will show all inventory items associated with a category given the category name is 100% identical to the category name you want to use to display.  Meaning, uppercase and spaces and punctuation all the same.

  • [wpinventory category_slug="category-slug"]

    – This is the slug of the category as defined in the dashboard under the category you setup.  To edit the slug simply navigate to the WordPress dashboard under the WP Inventory tab and “Categories”.  Editing the category will give you the ability to change the slug.  This enables you to manager your category names and the slugs for the URLs you want to use separately.

  • [wpinventory category_id="5|7|12"]

    – Using this attribute will allow you to display only one category at a time, or multiple categories.  To display only one category, just put in that category ID and that is it.  To display multiple categories, simply separate each ID with a pipe (|) separator.

  • [wpinventory inventory_id="175"]

    – The attribute inventory_id will show only that one inventory item.  Put this on individually made inventory pages for example.

  • [wpinventory product_id="175"]

    – Alias for inventory_id above, this does the same exact thing.  It allows you to list one specific item.  In this case the attribute is specific to the point it is a “product”.  You may pick which you prefer to use.

  • [wpinventory inventory_slug="product-slug"]

    – Another way to list one item specifically.  Using it’s inventory slug label.

  • [wpinventory user_id="5"]

    – Here we can show all inventory items on a page associated to the user “x”. Meaning, all inventory items entered by that specific user and that user alone. You will have to know the user’s ID for this. You can find that by hovering the user in the WordPress dashboard under the “users” tab. When you hover that user, at the bottom of your screen it should show the URL of that user link. In that URL, you will see “user_id=”x”. That is the id you need for this shortcode attribute to work. Also, you will not be able to see your own personal user ID while you are logged in. WordPress just does not show it to you. So, you need to log in as another user. If you are the only user or, were the first user, then your user ID is “1”.

  • [wpinventory page="3"]

    – A numeric value to indicate which page in the number of pages to view.

  • [wpinventory page_size="15"]

    – A numerical value to set how many items to display on a page before having to go to the next page.

  • [wpinventory inventory_search="search term here"]

    – Any text you want that will be “searched for” within the inventory item.

  • [wpinventory inventory_status="2"]

    – Filter items by their status. Uses the status ID of the status, and works with custom or edited statuses as well. By default:

    • Active    = 2
    • Inactive = 1
  • [wpinventory hide_low="0"]

    – This is an override setting.  If you set this to “0” then that is saying “do not” honor the hide low quantity setting in the general settings.  Which will in turn display all inventory.

  • [wpinventory hide_low_quantity="20"]

    – This is another override.  Say you have your general quantity hide low set to 30 in the system.  This example would now show any quantity that is 20 or more.

    Example of these two together:

  • [wpinventory hide_low="1" hide_low_quantity="20"]

    Note:  We set the hide_low equal to : 1 –  This means “enable hide” and has to be accompanied by the hide_low_quantity parameter.

    – The only necessary usage of this shortcode combination is if you do not have a general hide low quantity setting set, however for this particular list of items you do want to hide items of a certain quantity or lower.

  • [wpinventory inventory_year="2018"]

    – This will show inventory belonging to a specific year.

  • [wpinventory backlink="off"]

    – This will hide the back-link that is on the details page if set to “off” or “false”.

Advanced User Control

If you are a licensed user and have a valid Advanced User Control license, then you may do the following to display inventory items on the front end.  Please note that these options are only available for the Advanced User Control version 1.1.0 and up.

  • [wpinventory user_id="self-or-none"]

    – This will display all of the inventory items for the logged in user.  If logged out, it will display no inventory items at all.

  • [wpinventory user_id="self-or-all"]

    – This will display all of the inventory items for the logged in user.  If logged out, it will display all of the inventory items.

  • [wpinventory user_id="self-or-template" template="your-template-file.php"]

    – This will display all of the inventory items for the logged in user.  If logged out, it will display a custom template of information utilizing the template override system.  Simply create a .php file and put it in the “views” folder.  Then, above in the shortcode where it says “template=”, provide the file name.  For example:  file.php.  The “.php” extension isn’t necessary but can be included.  This allows for a much better user experience and allows you to give the proper directions to the user in order to view or get started to view inventory items on your site.

Advanced Inventory Manager

  • [wpinventory type_id="1"]

    – Accepts a number value for the ID of the inventory type you wish to display.  Does not support multiple IDs due to the fact you can set the display setting differently for each type of inventory based on the amount of fields in each type you have.


  • [wpinventory location="1|2|3"]

    – Accepts a number value for the ID of the location you wish to display.  Can also be separated with a comma to add multiple locations.  IDs are found in the location table in the dashboard admin.

Reserve Cart

  • [wpinventory_checkout]

    – Place this shortcode on a page you intend to display the checkout cart and reservation form for the user to complete the reservation.

  • [wpinventory_cart]

    – Displays the cart contents and totals with a button to go to checkout.

Advanced Search Filter

The Advanced Search Filter can be displayed on the frontend using the shortcode:


You can find more details on these filters and the available shortcode parameters in the Advanced Search documentation.

Sorting Display

  • [wpinventory order="name DESC"]

    – This will sort the inventory on the page by the ‘name’ field and it will order it in reverse alphabetical order.  So from Z to A.  If you leave out the “DESC” then it will sort the inventory by the ‘name’ field in alphabetical order, or from A – Z.  Lastly, the “DESC” is not case sensitive.  So it could be “DesC” and still work. You can do this type of combination for virtually any field EXCEPT date fields.  For example, to order by the “Sort Order” values you would use:

    [wpinventory order="inventory_sort_order"]
  • You can use any of the standard fields listed at the top of this page to order items.

Ordering by two or more fields

  • [wpinventory order="quantity DESC, number ASC"]

    – allows multiple sort parameters. This would sort first by quantity descending, then number ascending.  Try using other combinations to suit your needs.

Combining Shortcode Attributes

You can also combine shortcode attributes, like the example below. You can find more information on the Shortcode Attribute Linking page.

[wpinventory page="3" page_size="15" category_id="5|7|12"]