I would like to add different Facebook pages onto my Wordpress website using the Elementor 'single posts' template, a shortcode, and WP user frontend (WPUF) as a way to input the relevant fields (i.e. the Facebook URL, as it relates to this question). The basic idea is that a business owner can input their general details into a WPUF form, and the post will display this data along with a preview of their Facebook page for my website users to browse through.
I have added the function (shown below) into my functions.php file and used the shortcode [facebook_integration] on my elementor single post template page. After numerous hours of playing around with the code I still cannot get it to work properly.
Any assistance that you could provide on this matter would be greatly appreciated!
Note - The only modification that I have made to the Facebook source code is attempting to call my custom post meta "facebook_url" into the data-href section.
<?php
function facebook_integration ( $value, $post_id, $atts ) : string {
ob_start ();
$value = get_post_meta($post->ID, 'facebook_url');
?>
<div id="fb-root"></div>
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v18.0" nonce="Ck9XkSpW"></script>
<div class="fb-page" data-href=“facebook_url” data-tabs=”timeline” data-width=”500″ data-height=”” data-small-header=”false” data-adapt-container-width=”true” data-hide-cover=”false” data-show-facepile=”true”></div>
<?php
return ob_get_clean();
}
?>