Hi there,
On my site: versteckter Link
I have a view that shows different infos about the camp. The bottom one is "Pris" (Price) and i would like to show the price of the camp - but as a dynamic source since every camp obviously has different prices.
On the content template you guys set in a shortcode. What i did was trying to copy this code and just paste it into the view where i want it, but nothing shows up.
You are using the legacy editor for Views and templates?
Rather than copy and paste an existing shortcode, while editing the output of the View use the Fields and Views button to insert the shortcode for that field in the place it is required.
I did copy the existing shortcode from the tempalte and set it into a classic field in the view. But it is not working. Do you have any suggestions or a guide on how to do it?
What do you mean by every camp obviously has different prices? Is the price a custom field on the camp? Or does it come from the related product(Relationship: Camps Products)?
Can you give an example of a camp that has multiple prices? What price to choose from?
Or is each camp linked to only one product?
So 1 camp has 1 price. But 2 camps can have different prices - so yes there is a relation between 1 camp and 1 product. Just like on the content template of each camp.
my question is: How do i show the price of the camp in the view? because it seems like i can not just copy the shortcode from the content template. It does not work when i do it however.
The shortcode will not work with a simple copy-paste. Because the shortcode expect to find the data in the current post(In this case: the camp post). A shortcode can pull the data from the parent post in a One-to-many relationship, but it can't take it from a child post. This uses the item attribute https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
Currently, the Camps<>Products relationship is a one-to-many relationship, so you can't get product's data inside the camp page using shortcode. But, you can pull the camp's data inside the product page, because the camp is a parent for the product.
This being said, the only way, is to create a view that will pull the products linked to the camp, and display the price inside of it. The view needs to have a filter on the relationship related to the current post in the loop. Check this screenshot versteckter Link
I created the view here versteckter Link
And included it inside the page's view with a shortcode:
[wpv-view name="camps-product-price"]
It displays the price, but in blue. So, I'll let you fix the color of the price using CSS as you did before. versteckter Link