Support » Plugins » Hacks » How to Change Domain But Retain Facebook Likes

  • Hi all,

    We are just moving out of beta and must change our domain name (bummer) but do not want to loose our thousands of facebook likes.

    HTML code on our page for the likes is as follows:

    <iframe frameborder=”0″ scrolling=”no” allowtransparency=”true” style=”border:none; overflow:hidden; width:50px; height:65px;” src=”″>

    PHP code (sharebox.php) for likes inside the sharebox wrapper looks like this:

    <div class=”panel” title=”Like on Facebook”>
    <iframe src=”<?php echo rawurlencode(get_permalink()); ?>&layout=box_count&show_faces=true&width=50&action=like&font=arial&colorscheme=light&height=65″ scrolling=”no” frameborder=”0″ style=”border:none; overflow:hidden; width:50px; height:65px;” allowTransparency=”true”></iframe>

    <?php } ?>

    The href defaults to the current page/permalink normally but I would like to be able to use a wordpress custom field to insert our old page url for articles pre domain switch and revert back to the current permalink for post domain switch posts.

    Can anyone suggest an approach for this? I am not a coder unfortunately.

    Alternatively, if there is another way of doing this that would be great too.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz


    I’m not sure how sophisticated the FB Like mechanism is. Will it happily return the likes of another website to the iframe if so requested? Or does it check the referer field and throw an error if there’s no match? Or some other verification mechanism?

    If it is the first condition, you can just str_replace your old domain into the new permalink, like so:
    <?php echo str_replace('newdomain', 'olddomain', rawurlencode(get_permalink())); ?>

    You might try a simple manual test first, place the Like iframe html on a webpage of your new domain, but with the old domain passed to facebook as the href url parameter. Confirm facebook sends the Likes belonging to the old doamin without issue.

    Thanks bcworkz, probably correct not that not that simple. Will continue my research. Anyone have any thought beyond the below pls chime in.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to Change Domain But Retain Facebook Likes’ is closed to new replies.