I want to add post/page url on Facebook/Twitter share but due to my low knowledge of knowledge in wordpresss i don't know how to do that.
I add echo get_permalink()
but that doesn't work.
Code located on function.php
$string .= '<li class="facebook" id="facebook"><a href="https://www.facebook.com/sharer/sharer.php?u=echo get_permalink()">Facebook</a></li>';
You are mixing your php..
change this
$string .= '<li class="facebook" id="facebook"><a href="https://www.facebook.com/sharer/sharer.php?u= <?php echo get_permalink() ; ?> ">Facebook</a></li>';
to this
$string .= '<li class="facebook" id="facebook"><a href="https://www.facebook.com/sharer/sharer.php?u='.get_post_permalink().'">Facebook</a></li>';
or for readability
$string.= '<li class="facebook" id="facebook">';
$string.= '<a href="https://www.facebook.com/sharer/sharer.php?u=';
$string.= get_post_permalink();
$string.= '">Facebook</a></li>';
have a look into php string concatenation
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.