Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Social Sharing / tell a friend plug but specify which URL to share

I would recommend rolling your own. Use the sharethis api or addthis. Then you can use get_permalink(); for the url parameter.

function wpu_share() {
        $url = get_permalink();
        $title = get_the_title();
        $add_this="st_url="".esc_url( $url ).'"'; ?>

    <span class="st_facebook_large" <?php echo $add_this; ?> displayText="Facebook"></span>
    <span class="st_twitter_large" <?php echo $add_this; ?>  displayText="Tweet"></span>
    <span class="st_linkedin_large" <?php echo $add_this; ?> displayText="LinkedIn"></span>
    <span class="st_email_large" <?php echo $add_this; ?> displayText="Email"></span>
    <?php }

 add_action('wp_footer', 'wpu_share_js' );
 function wpu_share_js() { ?>
        <script type="text/javascript">var switchTo5x = true;</script>
        <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
       <script type="text/javascript">stLight.options({publisher:"ur-xxxxxxxxxxxx"}); </script>
<? }

Update

You will need to pass a variable to the thank you page that references the post id of the course they signed up for then you can use this to get the right url.

$url = get_permalink( $post_id );  

// You will need to pass the post id to the thank you page using a query string or another method.

To use a query string append ?id=$post->ID to the end of the redirect to the thank you page. Then on the thank you page:

if (isset( $_GET['id'] ) $post_id = (int) $_GET['id'];

For security make sure you use esc_url() where ever you are using the $url variable.

Related Posts:

  1. How to setup shared content between main site and subdomain?
  2. Is there a way to change a post’s thumbnail image(s)?
  3. Sending post information to a coldfusion site.
  4. Whenever I am sharing a post wordpress phrase is automatically added, can anyone help?
  5. Subscribers only receive a snippet of my post
  6. White image when I share my site
  7. Featured image not showing on facebook share
  8. Add Flatr button to Sharing option
  9. Is it better to set social media sharer in entry-footer.php or comments.php in WordPress blog?
  10. Post sharing in social network
  11. How do I remove social buttons from the “Blog” section of my theme?
  12. False ‘Sharing Violation’ Xcopy error message
  13. Two WordPress sites sharing the same content
  14. WP Multisite: load content from site X on site Y
  15. Storing posts social counters by using transient api
  16. Shared Content but “Updatable” Through the Main Site
  17. Default image for homepage when shared in social media
  18. Share buttons on article footer
  19. List repeating share links
  20. One WordPress install serving multiple virtual hosts
  21. Facebook sharer and parameters in URL
  22. Edit Custom Links Menu markup: Making a Social Media Menu with linkable icons
  23. How can i disable a plugin for a mobile phone?
  24. Get total social share count (Facebook, Twitter, Google+. Pinterest)
  25. Retrieving Google Plus share count with wp_remote_post
  26. Social sharing post’s shortlink instead of permalink
  27. How to generate “og:image” meta for Facebook sharing when the image in the post is not featured?
  28. Open graph problem: Showing wrong description of homepage while sharing on Facebook [closed]
  29. Only display link to author social media when it exists [closed]
  30. Multiple social buttons with a fast loading? [closed]
  31. Changing Social Media
  32. How can I override print_embed_sharing_dialog() in WordPress 4.5
  33. what function can I use to automatically output og tags per page/post?
  34. Is it possible to use Twitter intents with the post’s image in WordPress?
  35. How to have a “clean” post content, for excerpt and social networks sharing
  36. Automatically add simple custom buttons for print, Facebook share, & Tweet in Posts [closed]
  37. Social sharing toolkit is not showing on ajax load
  38. Add share links to all blog posts on homepage
  39. LinkedIn Social Wall | Is there a plug-in (Free / Paid) to display a LinkedIn feed in a social wall (not just a feed)?
  40. Sharing images to social media – issue with aspect ratio
  41. Modify foreach loop for social sharing links?
  42. buddypress activity social share
  43. How to integrate Facebook Share button without code?
  44. Facebook social publisher and custom post type fields [closed]
  45. Skeleton Child Theme Add Icon Bar to Header Flex Grid
  46. Can i Use own Facebook App ID with this Social Comment Plugin? [closed]
  47. Can I develop a social networking Site using WordPress and its Plugins? [closed]
  48. How to add FB like + share AND also other Social Buttons on ALL pages and posts?
  49. 2 WordPress sites with 2 databases but sharing the same users
  50. Post image lacking when pasting link into Facebook despite the correct og:image meta tag
  51. Trouble displaying featured image as thumbnail when using Facebook share
  52. inviting people to blog and editing roles
  53. No post image when pasting link into Facebook
  54. the_permalink on the homepage vs posts for sharing links
  55. how to set social icons to product / post template (Auros theme)? [closed]
  56. How To Post WordPress Custom Post Types to Twitter via IFTTT
  57. Social sharing is not working as expected
  58. add share buttons above my posts without plugins
  59. How to add social follow button to header? [closed]
  60. How to replace URL protocol using PHP?
  61. Keeping social share count after changing WordPress Permalinks
  62. How to share post?
  63. Social share buttons text shows up on post excerpts
  64. “This site is under development” when sharing on Facebook
  65. Sharing Buttons not Working – Sharing Settings [closed]
  66. Two different pages that share the same content?
  67. Store SNS share value via function.php
  68. Followers for WordPress [duplicate]
  69. Featured image for social sharing ot author archive page
  70. open graph image being overwritten by gravatar logo?
  71. How to create social Share Buttons Without Plugin
  72. how give a link to an Elementor Pro widget with variable part
  73. Are there any Inbuilt Social media sharing icons
  74. share sample of website designed in localhost with clients
  75. How can I automatically display the section link on my one-page Elementor website?
  76. How to add extra custom social icons to page with same style?
  77. Author social media aren’t shown on the page
  78. WordPress Sumo Plugin not showing all images on clicking pinterest icon
  79. How can I share my wordpress site with a friend?
  80. Linkedin not returning right info
  81. how can I easily clear the “header is malformed” error when trying to reconnect social accounts in jetpack
  82. Social sharing conflict with Rewrite rules
  83. Facebook Share Permalink Javascript href
  84. How to remove author from Social sharing links?
  85. Social sharing plugin directing to blank page after post sharing
  86. sharing the same cookie session with multiple wordpress installs on the same domain?
  87. Featured Image and Facebook
  88. Facebook and Google+ sharing suddenly stopped working properly in WordPress
  89. Social Media Feather icons not displaying for each post
  90. Share buttons in some specific posts in WordPress
  91. How do I add a WordPress role that can only see scheduled and pending posts?
  92. Share content between two different sites in same domain
  93. Add social media icon in header area
  94. Encode URL picked up by Digg Digg
  95. WordPress multisite and one database
  96. how can i display share images for each article?
  97. Slick Social Share Buttons plug-ins with Responsive theme – number of tweets link problem
  98. Using wp_enqueue_script with social media buttons?
  99. how to get confirm that a shared user are inivited by member of website?
  100. How to make a share-this window drop when reaching end of post?
Categories sharing Tags sharing, social-sharing
How can I let users open the site for other visitors?
Exclude Category From Home Page, Display Posts on It’s Own Page?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress