I’m using this code to create the Share button, but it only work to share a fixed link.
I wanna make this hook available for all post, and with each post, it will share itsefl link but not a fixed link like the code below.
Here is the code:
<!– Your share button code –>
<div class=”fb-share-button”
data-href=”[https://vantuanle.com/blog/cai-youtube-vanced-cho-iphone/]”
data-layout=”button\_count”>
</div>
I try to find the solution but it tell me to use this php code to single.php after
<header class=”entry-header”>…</header>
add\_action( ‘the\_post’, ‘add\_facebook\_share\_button’ );
function add\_facebook\_share\_button() {
global $post;
$permalink = get\_permalink( $post->ID );
?>
<!– Your share button code –>
<div class=”fb-share-button”
data-href=”<?php echo esc\\\_url( $permalink ); ?>”
data-layout=”button\_count”>
</div>
<?php
}
but my single.php file doesnt has that code so i cant insert.
