Skip Navigation

[Resolved] Featured image from custom field

This support ticket is created 6 years 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.

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 reply, has 2 voices.

Last updated by Luo Yang 6 years ago.

Assisted by: Luo Yang.

Author
Posts
#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/