Skip Navigation

[Resolved] Creating a custom post type having a facebook post (as a field) to be embedded

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

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1127511

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?

#1127648

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.

#1128057

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?

#1128098

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!