Skip Navigation

[Resolved] Filtering by custom fields in a related post

This support ticket is created 5 years, 7 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 1 reply, has 2 voices.

Last updated by Beda 5 years, 7 months ago.

Assisted by: Beda.

Author
Posts
#1233075

In reference to this ticket: https://toolset.com/forums/topic/cannot-filter-results-by-custom-field-from-child-relationship/

Is there a code example available to create fields in the desired CPT that retrieve/share the values from another CPT so they can be used be filtering for this example?

#1233195

You would have to set up some Custom Code which for example updates fields in a Post of Type A when you save a Post of Type B.

Such code would get hooked at the save_post action of WordPress.
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post

You would use get_post_meta() to get the Post Fields values from the saved post and then update_post_meta() to update the Fields in the other post:
https://developer.wordpress.org/reference/functions/get_post_meta/
https://developer.wordpress.org/reference/functions/update_post_meta/

This does not require Toolset to work, or Toolset's API to solve it, it's all based on PHP and WordPress, which is something we can not support here, therefore.
https://toolset.com/toolset-support-policy/

I can help you review the code if required, however, we cannot produce ready to use samples for these tasks as it does not require Toolset Features.