I have a two buttons to share content from a web page (one of fb and one of tw).
I am using inlcude to repeat the content on all pages <?php include 'share.php';?>
. The problem is that Facebook asks me for a specific url for each page, how can I achieve this if include only allows me to repeat content? Is there a way to detect the URL according to the page where I am? With Twitter, there is no problem (it automatically detects it).
<span class="text-share">Comparte:</span>
<div class="bt">
<a class="bt-facebook" href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fkhapac.com/portafolio-pecsa-multimedia/">Facebook</a>
</div>
<div class="bt">
<a href="https://twitter.com/share" class="bt-twitter" data-hashtags="Khapac" target="_blank">Twitter</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</div>