Hi support,
I am trying to set up the output of my product archive. Within it I want to display the value of a custom text field from a parent CPT(bestemmingen). The displayed text must link to the parent post. It shows the the right value of the custom field but the link goes wrong. See link to "Sardinië". When i set it up with the shortcode " wpv-post-link" the link works fine. See second link "Rondreis Sardinie"
hidden link
I have used the following code.
[types field='landnaam' item='@bestemming-product.parent'][/types]
The permalink for products " rondreizen" and for the bestemming parent CPT it is "rondreis"
I think I am making a stupid mistake but cannot find out what it is. Can you help me out?
Thank you .
Kind regards
Edwin
Hello Edwin and thank you for contacting the Toolset support.
The code you have added should work for a parent post in a One-to-Many relationship. You may also use an unassigned content template that will generate the link and put it inside of your code using the item attribute as you have done.
If it does not, we'll need to debug why. Please allow me temporary access to your website and let me check it closely. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **
Thank you Edwin for the access credentials.
It seems that the shortcodes break inside the "Fields & Text" block, probably because of switching from visual to HTML. I would suggest using a Classic block with the code that you have added to your first reply.
As you are building the archive template with blocks, I would rather suggest using a Toolset "Button" block, and configure it to pull the custom field and the URL from the related post. Use the first for the button text and the last for the button URL.
I created an example on your website, check how on this screenshot hidden link
The "Fields & Text" blocks are still there, I'll let you remove them.
I hope this helps. Let me know if I have missed something.
Hi Jamal,
I already noticed that the button function would work like that. You would expect that there was also such a function purely for text. A dynamic text combined with a dynamic URL. I suppose you could make the button transparent and make it look like a normal text link. But it does not seem to be the proper way to go.
What do you exactly mean with a Classic Block? I have added the code in classic HTML Block ( see attachtment).
I have also made a view in the classic editor ( for the bestemminge CPT) on my homepage with the follwing code:
[types field='landnaam'][/types]
They both result in wrong URL.
Can you take a last look at it for a solution?
Thank you.
Kind regards
Edwin
Hello Edwin,
I tried a Classic block but it did not work for it too. So I tried the unassigned content template. First I switched the editing mode for the content template "Landenlink" to the classic editor and I used the following code:
<a href="[wpv-post-url]">[types field='landnaam'][/types]</a>
Then I used the content template inside the archive loop with a shortcode block using:
[wpv-post-body view_template="Landenlink" item="@bestemming-product.parent"]
Check the result here hidden link
I hope this helps. Let me know your feedback.
My issue is resolved now. Thank you!