How to Add Facebook Share to Index.php
-
I’m trying to add Facebook Share buttons on my index.php, so that they show up after every article on the homepage, but for some reason the button always links back to the main page rather than the permalink for the specific blog post. Here’s what my code for the loop looks like right now:
<?php while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1> <div class="entry"> <?php the_content('Jump in »'); ?> <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?> <?php if(function_exists('the_views')) { the_views(); } ?> </small> <strong><a name="fb_share" type="button_count" href="https://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>">Share</a><script src="https://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></strong> <br /> </div> <p class="postmetadata">Read all about <?php the_category(', ') ?> <?php the_tags( ", ", ", "); ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p> </div> <?php endwhile; ?>
The bolded section is what should be the FB share code. You can check out the problem right now — the site is https://evilbeetgossip.com. Thanks!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘How to Add Facebook Share to Index.php’ is closed to new replies.