What is considered the best method for 'like' buttons (same for twitter and google+) so that multiple pages use the same one?
If i have an article spanned over several pages, it's giving each page a unique like button and i want it to be the same one. I'd also like to try an automated solution if you know of one.
Using wordpress, I'm currently thinking of using a custom field to input the url directly, but that's not as automated as I'd like. What is the solution?
Currently thinking this might be the easiest:
<?php
//Attempt to get page one of a reviews url for social bar on extra review pages.
$socialfield=get_post_meta($post->ID, 'social_url', true);
//if isset & not blank else use the_permalink()
$socialfield=(isset($socialfield) && $socialfield!='')?$socialfield:the_permalink();
where 'social_url' is the custom field.
then do this:
<div class="fb-like" data-href="<?=$socialfield?>" data-send="false" data-width="450" data-show-faces="true"></div>
I just wish for a more automated method or at the very least confirmation that this is probably the best way to go.
when you get the
like
button you will get the codes something like this in HTML5 TabJust note the
data-href="http://www.example.com"
attribute,now what to do, just get the parameter from the url something like
http://www.example.com/post/first-post/
and set this value indata-href
attribute.