php - Wordpress add page/post url/path on Facebook/Twitter share -


I want to add a post / page URL to Facebook / Twitter share, but due to less knowledge of knowledge in WordPress,

I add echo get_permalink () , but it does not work.

The code is located at function.php

$ string = '& Lt; Li class = "facebook" id = "facebook" & gt; & Lt; A href = "https://www.facebook.com/sharer/sharer.php?u = echo get_permalink ()" & gt; Facebook & lt; / A & gt; & Lt; / Li & gt; ';

You are mixing your php ..

Change

  $ string = '& Lt; Li class = "facebook" id = "facebook" & gt; & Lt; A href = "https://www.facebook.com/sharer/sharer.php? U =  

this

  $ string. = '& Lt; Li class = "facebook" id = "facebook" & gt; & Lt; A href = "https ?: //www.facebook.com/sharer/sharer.phpU = 'get_post_permalink ().' '& Gt; Facebook & lt; / a & gt; & lt; / li & gt;';  

or for readability

  $ string = '& Lt; li class = "facebook" id = "facebook" & gt;' $ string. '& Lt; a href = "https://www.facebook.com/sharer/sharer.php? U = '; $ String = Get_post_permalink (); $ String = '' & Gt; Facebook & lt; / A & gt; & Lt; / Li & gt; ';  

have a look at


Comments