Plugin Demo: Products in a Table
This demo shows how to add ratings to the post/page without having the ratings connected to actual WordPress entities. The example is for showing products inside the table on the page.
The catch here is that these products are not part of WordPress – they are not posts or any other data, they might be random products just linked for affiliate purposes. In this demo, the product’s ratings are assigned to the new rating type, belonging to Custom entity, where we created Type called ‘Products’.
Create new rating type
For this purpose, we create ‘Products’ rating type inside the Custom rating Entity. Open the ‘Rating Types’ panel, and click Edit for the ‘Custom’ Entity. Add, new rating type, it will look like this:
Now, we have the Entity/Type, but we also need a unique ID’s to identify these products. Since they are not in our system, they don’t have ID’s. If you have some your internal ID’s that you will always use for same products, that is great, use them (as long as they are positive integer numbers). If not, think of the way to make them unique. Here is the suggestion: these ID’s can be created based on the ID of the page where the table is added, with added 2 zeroes and numbers 1 to 5 (5 rows/products). And, if the first product is used somewhere else, make sure to use this exact ID in all places so that ratings will be preserved. Also, you can simply assign sequential ID’s from 1 up, again make sure to use same ID’s for same products.
Create a table in the page
Create HTML table (or some other table), and for each product add the shortcode like this:
[gdrts_stars_rating type="custom.product" id="228001"]
Type is set to Custom entity, Product type. And, ID is our pseudo unique for each product. If you have 5 products, ID’s will be 228001, 228002, 228003, 228004, 228005. Or, simply use 1, 2, 3, 4, 5.
To see it in action, check out the Live demo page.
3 thoughts on “Plugin Demo: Products in a Table”
Thank you for this explanation!
Question: “integer” numbers?
Doesn´t (positiv) integer mean up to 32.767 ?
Or do you mean LONGINTEGER up to 2.147.483.647 ?
Integer ID for this is defined as UNSIGNED BIGINT in MySQL, and it can be from 1 to 18.446.744.073.709.551.615.
When I use gdrts_stars_rating_list with personalized ratings, not associated with a page, etc., as the example above, list appears without names. Is there some way to manually associate a name to each of the ratings [gdrts_stars_rating]?
[gdrts_stars_rating_list type=”custom.Comics” limit=10 template=”shortcode” style_size=20 style_type=”font” style_font_name=”heart”]
[gdrts_stars_rating id=1 type=”custom.Comics” style_type=”font” style_font_name=”heart” template=”expanded” style_size=20]