Skip Navigation

[Resolved] Set featured img of new post (cpt) to be same as it's parent post featured img

This support ticket is created 7 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 7 years, 11 months ago.

Assisted by: Nigel.

Author
Posts
#397817
Screenshot 2016-05-12 19.55.32.png
Screenshot 2016-05-12 19.48.31.png
Screenshot 2016-05-12 19.49.20.png

I am trying to: add new posts using cred form for adding that post from the current parent item All works fine except the assignment of a featured image from the parent post. I want the featured image of the new post to have the exact same featured image as it's parent.

I visited this URL: hidden link

I expected to see: featured image of the model 'att-u-verse-tv-point-anywhere-rf-remote-control-remote-control' which is the parent of the post (custom post type 'x').

Instead, I got: my default featured image which is set when there is not featured image...

In the image below with the + sign on the left (model image)....that is what is clicked when I want to add that model as an X in my collection. In the other image, that is the content template showing the newly added X from the model (model image). I attempted to add a hidden default post field in as highlighted in the code image attached, but it doesn't work....

Happy to give credentials and access ad Admin....I am using some custom code there to get the post id of the parent based on the model id and that is returning the URL of the parent featured image....just not assigning it as the featured image of the new child post.

#398031

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

As I understand it you have a hierarchical custom post type where you add child posts via a CRED form shown on the parent post, and you want the child post to automatically inherit the featured image of the parent post.

There is a limitation here.

The CRED form to add the child post, if you include the shortcode to add the cred_field '_featured_image' then that is going to display the form UI for the user submitting the form to select a file from their computer to upload as the featured image.

You can't trick the shortcode into using an existing featured image (from the parent or anywhere else) via its value because that is not how it is designed to work.

You would need a custom PHP function that hooked into the form submission (via one of the CRED hooks described here: https://toolset.com/documentation/user-guides/cred-api/

Featured images are stored in the wp_posts table as posts of type attachment where the post_parent is the id of the post it is attached to. Any one post (including attachments) can only have one post_parent, meaning you would need to duplicate the attachment post and set the parent_post id to that of your newly created child post.

Sorry, but I can't write the code for you, but if you or your developer are familiar with WordPress hooks it is relatively straightforward.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.