WordPress.org

Forums

Hardcode "like" into post footer (6 posts)

  1. stuart_doughty
    Member
    Posted 4 years ago #

    Hi, as the topic states i am trying to hardcode a facebook like button into my blog site. I tried cheating and copying the already intergrated twitter feed code but when navigating to the site it told me there was a server error.

    This is the twitter code i tried:

    <div class="twitter_link">
                        <a target="_blank" title="Share this article with your Twitter followers" href="http://twitter.com/home?status=Reading%3A+<?php the_title(); ?> - <?php
                         $turl = getTinyUrl(get_permalink($post->ID));
                         echo $turl;
                         ?>" rel="nofollow" class="social-bookmark">Tweet Article</a>
                         <img alt="Tweet Article" src="<?php bloginfo('template_directory'); ?>/images/twitter.png"/>
                    </div>

    but replaced it with the following:

    <div class="facebook_link">
                        <a target="_blank" title="Share this article with facebook" href=""http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?
                         echo $turl;
                         ?>" rel="nofollow" class="social-bookmark">Like Article</a>
                         <img alt="Like Article" src="<?php bloginfo('template_directory'); ?>/images/fbr.png"/>
                    </div>

    Any ideas where im going wrong? I am adding the appropriate CSS code to work with the php but i just get internal server errors.

    Here is a link to my site so you can see where i want it: http://www.photosbystuart.co.uk

    Thanks in advance

    Stuart

  2. CyberAlien
    Member
    Posted 4 years ago #

    What is $turl for? It seems to be in wrong place and has ? before it that doesn't make sense. Try this:

    <div class="facebook_link">
                        <a target="_blank" title="Share this article with facebook" href=""http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>" rel="nofollow" class="social-bookmark">Like Article</a>
                         <img alt="Like Article" src="<?php bloginfo('template_directory'); ?>/images/fbr.png"/>
                    </div>
  3. stuart_doughty
    Member
    Posted 4 years ago #

    Ok that works and looks like its in the right place, however when i click it, it just reverts me back to my own website instead of requesting for me to login to facebook to share the article. it's worth noting that i really don't have much of a clue about php, i grabbed the code from website.

    your help is greatly appreciated.

  4. sdelamorena
    Member
    Posted 4 years ago #

    The facebook like button use iframe. It's impossible do button as we do with Twitter.

    Try this:

    <div class="facebook_link"><iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&layout=button_count&show_faces=false&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:100px; height:30px"></iframe></div>

    You have more info on Facebook Developers: http://developers.facebook.com/docs/reference/plugins/like/

  5. Digital Raindrops
    Member
    Posted 4 years ago #

    Have a look at this post and pick out the code bits you need!

    HTH

    David

  6. stuart_doughty
    Member
    Posted 4 years ago #

    sdelamorena: your solution worked. Thank you so much

Topic Closed

This topic has been closed to new replies.

About this Topic