On a content template I have created a view which I include by shortcode, which shows the number of reviews, where reviews are a CPT with a child relationship to the current product CTP. This part works fine.
I then a view on the page which displays similar products. Posts of the same CPT. In the loop item of that view, I the "reviews count" view is included. In this instance, it breaks and does not show the correct value or output.
I understand that the website is using the view named "Product: Reviews (count)" to show the count of related review posts, in the "Template for Products", twice.
Once for the current product and the other instance is inside the loop of the view "Product: Related products".
I've changed the "Product: Reviews (count)" view's query filter settings to "The post with ID set by the shortcode attribute: wpvrelatedto", so that it is not dependent on the current post or the post from the current view's loop, as we need to make it work for both these instances.
Through this change, we'll be able to pass the current post's ID using the "[wpv-post-id]" shortcode into the shortcode attribute "wpvrelatedto" and the view will use that as a reference to get the related posts:
I've made this change to both the shortcodes of this view in the template as well, but there is a separate challenge involved. No matter what change is made to the "Product: Related products" view it is for some reason not getting updated on the front end.
( I've tried disabling the view's cache and clearing the SiteGround Cache too )
Do you recall adding any custom code on the website, to change the output of the view "Product: Related products" or any other view for that matter?
Please also ensure all involved caches have been cleared and if the issue persists, I'll need your permission to download a clone/snapshot of the website.
During troubleshooting, I noticed that the following two views that were being used inside the template "Template for Products" were not saved properly and hence any changes that were being made to them were not getting updated on the front end.
1. Product: Related products
2. Product: Product reviews
I deleted them and recreated the new ones and they started working as expected.