简体   繁体   中英

How to hardcode an URL to Digg Digg Facebook like button?

I'm using Digg Digg plugin (which is Open Source, Github here ) to show a floating social bar on my blog. It's working fine.

But I want to edit it so that if people click on the "Like" button, instead of the post being liked, I want my facebook page to be liked.

I understand that I need to change the dynamic URL used by the plugin to a hardcoded one. I looked up the plugin functions and found the following file named dd-class.php

I made the following changes in line 501:

Original

const BASEURL = "<script src=\"//connect.facebook.net/FACEBOOK_LOCALE/all.js#xfbml=1\"></script><fb:like href=\"VOTE_URL\" FACEBOOK_SEND FACEBOOK_SHOW_FACE VOTE_BUTTON_DESIGN ></fb:like>";

Edited to

const BASEURL = "<script src=\"//connect.facebook.net/FACEBOOK_LOCALE/all.js#xfbml=1\"></script><fb:like href=\"http://www.facebook.com/mypage\" FACEBOOK_SEND FACEBOOK_SHOW_FACE VOTE_BUTTON_DESIGN ></fb:like>";

This should work. But it is still taking the post URL. Can someone please guide me. :( I'm stuck.

Just FYI: My WP runs on Nginx and Varnish . I was wondering if Varnish is the culprit. So I tried to bypass Varnish too. But the problem persists, so most probably not a Varnish issue. I don't have any other caching plugin at work.

Well if you want that you must edit the file digg-digg.php instead the dd-class.php

So search inside the function dd_hook_wp_content() and edit (mine is in line 43):

//$postlink = get_permalink($id); //get post link

to this:

$postlink = 'http://www.facebook.com/mypage';

I hope this help you.

Notice that if you are working in localhost the Like button will not show because facebook need a dot to recognised as a valid url. So:

http://localhost/mysite.com/?p=1#comments

will not work but:

http://localhost.com/mysite.com/?p=1#comments

yes :)

You will see it for example when you work with wordpress

Have fun and voted me pls if help it you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM