Skip Navigation

[Résolu] Featured image from custom field

This support ticket is created Il y a 5 années et 5 mois. 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 réponse, has 2 voix.

Last updated by Luo Yang Il y a 5 années et 5 mois.

Assisted by: Luo Yang.

Auteur
Publications
#1140640

Support,

Right now I am inputting external URL's into custom fields to pull product images. Is it possible to trigger the featured image of a post from the custom field?

Thanks,
Charles

#1141099

Dear Charles,

I assume we are talking about this case, when user save a post, you are going to use the custom image field value as the post feature image(product image).

If it is, there isn't such a built-in feature within Toolset.

It needs custom codes, here are my suggestion:
1) When user save the post, you can use action hook save_post to trigger a PHP function
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post

2) In this function
- Get the custom image field value
https://codex.wordpress.org/Function_Reference/get_post_meta
- Retrieve the remote image file
hidden link
- Save it into wordpress media library
https://codex.wordpress.org/Function_Reference/wp_insert_attachment
- Save the media ID as post feature image(product image)
https://codex.wordpress.org/Function_Reference/set_post_thumbnail

But according to our support policy
https://toolset.com/toolset-support-policy/

this kind of custom codes is out the range of Toolset support, if you need assistance for it, you might check it with our Toolset contractors:
https://toolset.com/contractors/

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