I want to create a custom post type (CPT1) which will have fields to store a Title and a Facebook post (embedded in front-end preview).
Similarly I also want to create another custom post type (CPT2) with fields to store a Email and a Facebook post (embedded in front-end preview).
CPT1 and CPT2 will have one-to-many relationship i.e. Each CPT1 can be associated with several CPT2 but each CPT2 will be associated with only one CPT1. There is no separate view for CPT2 individually instead all associated CPT2 gets displayed in a list in each CPT1.
For embedded Facebook post which field type is more suitable? and what would be the ideal way to implement this?
The best way to implement an embedded Facebook post is to go to https://developers.facebook.com/docs/plugins/embedded-posts/ where you can generate code. In the popup, choose the "iframe" tab and you will see a code snippet like this:
<iframe src="<em><u>hidden link</u></em>" width="500" height="274" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" allow="encrypted-media"></iframe>
In Types, use a WYSIWYG custom field to store this code. Then insert the embedded post using a Types field shortcode in your Content Template or Template Layout.
Wordpress is already supporting embeds via url for many platforms including Facebook posts refer:
https://codex.wordpress.org/Embeds
Facebook also says it supports oEmbed refer:
hidden link
Ample examples in the form of page builders or plugins are already giving an option to implement same thing with just url of Facebook post which is the only thing we need to insert.
So don't we have any built-in feature/custom field in Toolset like Embedded media where we are just required to insert url and get the embedding work done?
In the solution you gave there will be repeated content for every post and will turn into unnecessary storage burden. Even when there is a change in Facebook platform usage, the entire website will turn into scrap for very brief time until every individual field value is updated. Also if you refer iframe embed code as in your solution the Facebook post url is lost and there will be no option to even change the embed code as per latest requirements of Facebook when Facebook makes platform changes.
The solution you suggest as best way to implement would be for now but it is not future-proof. So what should be the solution which considers these factors for future changes by Facebook and keeps easy life for website admin?
I thought Embedded media is only for videos/photos but after referring
https://toolset.com/documentation/customizing-sites-using-php/functions/#embedded-media
I tried to implement it by adding just Facebook post url and it works.
My issue is resolved now. Thank you!