Hi, I created a CPT "Channel" who is parent of Standard WP Post.
In this CPT I added an image fied "image_de_profil" with ACF (I use ACF because v5 are more option than toolset).
Now I want to display the image of the right parent channel into the curent Post user are in ?
Unsing Shortcode.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Marc,
Thank you for contacting our support forum.
What you can do is use the shortcode for the ACF field and then pass the parent post ID into it.
Example.
[acf field="field_name" post_id="Parent ID"]
The document below should be able to assist you with getting the parent ID.
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/
Please let me know if this helps.
Thanks,
Shane
Thank's it work when I added this code :
<img src="[acf field='image_de_profil' post_id='27']">
But I need to get the parent ID of the current post user are in because this a template. The Parent ID change for every single post.
So I need something like this :
<img src="[acf field='image_de_profil' post_id='code that get the right parent ID of the current post']">
But you can't nest shortcode into shortcode ? I think.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Marc,
You will need to get the parent ID dynamically .
The document below shows you exactly how you can get the parent id.
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-one-related-item-parent
Once you've generated the code, just add it to the post_id attribute of the ACF shortcode.
Please let me know if this was clear.
Thanks,
Shane
Hi,
I followed the link you provided and I try this :
<img src="[acf field='image_de_profil' post_id='[wpv-post-id item='@rel_cpost.parent']']">
But it's not working, I think is because a shortcode can't be nested into another shortcode.
Maybe I'm wrong, and I missed something on the document you sended, my english is not accurate.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Marc,
This is actually the correct way to do it.
If you split them up like this, does it give the correct result ?
[wpv-post-id item='@rel_cpost.parent']
Does the parent ID show up ?
Try this.
[wpv-post-field name="image_de_profil" id ="[wpv-post-id item='@rel_cpost.parent']
"]
Please let me know if this helps.
Thanks,
Shane
If I use only [wpv-post-id item='@rel_cpost.parent'] yes the right ID is showing up.
[wpv-post-field name="image_de_profil" id ="[wpv-post-id item='@rel_cpost.parent']
"]
This is not working.
Do you think it gona work if I use toolset field instead of ACF ? I used ACF because in ACF image field i can set minimum size for my image and file extension etc. I can't do it with toolset or maybe I don't know how to do it.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Marc,
It seems that the ACF shortcode doesn't allow for shortcodes to be used as an ID attribute.
You can use a toolset field for the image but your not able to set the image format or dimensions. However when you're displaying the image you can set what dimensions you want the image to display at.
You can try this and let me know if that would work for you.
Thanks,
Shane