Facebook messenger

Hi,
I have trying to add fb messenger code to the web site, it does not show the messenger, can you please let me know how to insert this code.

I have added it to functions.php as below…

add_action(‘x_before_site_begin’,‘fb_messenger’);
function fb_messenger () {

//my fb messenger code

<?php } apped: sorry forgot to add the sit elink ncg.mobipartners.in , this is http does fb messenger work on http or it need https url? if https is required, i can check on secured link. thanks Sridhar

Hi Sridhar,

Thanks for reaching out.

There is a missing part ?>, please change it to this

add_action('x_before_site_begin','fb_messenger');
function fb_messenger () { ?>

//my fb messenger code

<?php }

It should work on site, what will not work is if your site is HTTPS and you’re embedding the code from HTTP.

And I also see an existing code of the same facebook chat SDK from your site’s <head> which makes it a double declaration. I recommend disabling them first before implementing a new one, if it’s a custom code then you may remove it or if it’s a plugin, then I recommend disabling them. Unfortunately, I can’t pinpoint where the first embed code is coming from.

Hope this helps.

Hi,
I have installed some plugin to do this , now i have removed the plugins and added this code in the functions.php, can you check now, i see in DOM, its height and width are 0, looks like there is some issue with the loading of .jf from facebook ur.

thanks
Sridhar

Hi Sridhar,

I tried the code added to your site and it’s not working either on my end, the script is loaded but probably not executed. Could you try change it to this?

add_action('x_after_site_begin','fb_messenger');
function fb_messenger () { ?>

//my fb messenger code

<?php }

Then make sure the <script></script> code block is added right after this line <div class="fb-customerchat" attribution="setup_tool" page_id="656134464758986"></div>. If it’s still not working, then I recommend contacting a facebook developer.

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.