For each product you create with the WP Express Checkout Plugin, you can add categories and/or tags from within the product creation page. Adding categories and tags will then allow you to use a shortcode to display similar products on a WordPress page/post. This means that one shortcode can be used to display multiple products that share the same category or tag.
For example, a website owner might be selling a number of physical products but only wishes to display the handbags they have for sale. If all the handbags are placed within a category, they can all be displayed easily on one page using a shortcode.
Table of Contents
- Using Product Categories and Tags to Compile Similar Products
- Additional Category and Tag Shortcode Parameters
Using Product Categories and Tags to Compile Similar Products
Step 1) Categorizing and Tagging WP Express Checkout Products
For each product you create using the WP Express Checkout Plugin, you can add both categories and/or tags. Before you attempt to use a shortcode to display products from a category or tag, you will need to go apply these to the products first.
- Ensure you have the WP Express Checkout Plugin installed and activated on your WordPress website.
- From the WordPress dashboard, click on the “WP Express Checkout” and then on the “Add New Product” button.
- Within the product creation page, on the right-hand side, you will notice one section titled “Product Categories” and one section titled “Product Tags”.
- Add categories and tags that relate to the product, for example, ‘Jewellery’ or ‘Silver Jewellery’ might be a category suitable for a necklace.
- Ensure you “Publish” the product.
- Click on the “WP Express Checkout” “Products” menu, then select the additional products that you wish to add categories/tags.
Step 2) Display Products by Category or by Tag Using a Shortcode
Option 1) Displaying Products by Category
If you have placed a number of the products that you have created with the WP Express Checkout into a category, you can use the following shortcode to display all the products from one category in a neat grid display.
[wpec_show_products_from_category category_slug="the-cat-slug"]
To use this shortcode to display your products from a specific category, you simply replace “the-cat-slug” with the slug of your category. The slug of your category can be found by completing the following:
- Click on the “WP Express Checkout” menu and then on the “Categories” menu.
- You will see a list of the categories you have created and a column where the “Slug” of each category is listed.
- Simply copy the slug of the category in question.
- Replace the words the-cat-slug within the shortcode above with your category’s slug.
In the example shortcode below, I have created a category titled digital products which I intend on using to list all of the digital products I have for sale. I have replaced the-cat-slug with the slug of my category which was digital-products.
[wpec_show_products_from_category category_slug="
digital-products"]
Once you have your category shortcode, simply copy it and add it to a WordPress post or page using the “Shortcode Block”. Once the page is “Published”, your website visitors will see a neat grid display of all products from that category.
When you use the WP Express Checkout Categories Shortcode, it will display all products that have a specific category applied to them. An example screenshot where the category shortcode was used can be found below.
Option 2) Displaying Products by Tag
You can use the WP Express Checkout Plugin to create products, apply tags and then use a product tag shortcode to display similar items on a page or post. To achieve this, you follow the same procedure as you would to add a category to a product (in option 1) although instead of adding a category, you will add a tag. Then the tag shortcode can be used to display all products that have the same tag applied. The product tag shortcode is as follows:
[wpec_show_products_from_category tag_slug="the-tag-slug"]
To use this shortcode to display your products from a specific tag, you simply replace “the-tag-slug” with the slug of your tag. The slug of your tag can be found by completing the following:
- Click on the “WP Express Checkout” menu and then on the “Tags” menu.
- You will see a list of the Tags you have created and a column where the “Slug” of each tag is listed.
- Simply copy the slug of the tag in question.
- Replace the words the-tag-slug within the shortcode above with your tag’s slug.
I have added a number of products to the tag ‘low priced item’. The slug of this tag is low-priced-item and if I intended on displaying all the products that have the low priced item tag applied to on one WordPress page/post in a neat grid display, my shortcode would be as followed:
[wpec_show_products_from_category tag_slug="low-priced-item"]
The use of the WP Express Checkout product tag shortcode displays products with the same tag in a neat grid display. The product tag shortcode was used in the example screenshot below.
Additional Category and Tag Shortcode Parameters
Additional parameters can be added to the category and tag shortcodes. Using the additional parameters, the following can be specified:
- How many products are displayed per page
- How the products are sorted and the order
- The template and the search box
'items_per_page' => '30',
'sort_by' => 'ID',
'sort_order' => 'DESC',
'template' => '1',
'search_box' => '1',
The above parameter values are the default values of the category and tag shortcodes.
If you wish to only display 2 products from a specific category on a WordPress page, you would use the following shortcode:
[wpec_show_products_from_category category_slug="the-cat-slug" items_per_page
="2"]
The following shortcode was used to display products that share the same tag, at three items per page:
[wpec_show_products_from_category tag_slug="the-tag-slug" items_per_page
="3"]