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.