Earlier today a user contacted me and asked,
I am wondering if you are able to help with this. On the site ------.com, my client wants to have a place where users can easily copy and paste the html content of the article .... an example of that can be found on this site: http://www.copyrightfreecontent.com/newsusa/minor-leaguer-caught-new-dream-after-outfield-collision/In this article I share how we can a) construct a PHP variable consisting of Post's title, content and a 'originally published at' link b) use wp_localize_script() to send this variable to a .js file and set it as the text of our textarea c) use focus() method of the textarea to set up 'click to select content' Using jQuery to pluck the post's content is not recommended because usually plugins filter the content to inject their markup and we do not want all that in the 'shareable' content.
Step 1Add the following in child theme's functions.php:
To view the full content, please sign up for the membership.
Already a member? Log in below or here.