WordPress.org

Ready to get started?Download WordPress

Forums

How to Change Domain But Retain Facebook Likes (3 posts)

  1. cjyvr
    Member
    Posted 1 year ago #

    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="http://www.facebook.com/plugins/like.php?href=http://example.com/story1/&layout=box_count&show_faces=true&width=50&action=like&font=arial&colorscheme=light&height=65">
    </div>

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

    <div class="panel" title="Like on Facebook">
    <iframe src="http://www.facebook.com/plugins/like.php?href=<?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>
    </div>

    <?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.

  2. bcworkz
    Member
    Posted 1 year ago #

    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.

  3. cjyvr
    Member
    Posted 1 year ago #

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

    http://facebook.stackoverflow.com/questions/7197919/how-can-i-move-a-url-via-301-redirect-and-retain-the-pages-facebook-likes-and-o

Topic Closed

This topic has been closed to new replies.

About this Topic