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

add share buttons above my posts without plugins

Use This Code May Help You:

add_filter('the_content', 'br_content_with_social_buttons');
    function br_content_with_social_buttons($content){
        $url = urlencode(get_permalink());
        // Get current page title
        $title = str_replace(' ', '%20', get_the_title());
        $blog_title = get_bloginfo('name');
        $sharebuttons="
        <div id="social-share">
            <strong><span>Sharing is caring</span></strong> <i class="fa fa-share-alt"></i>&nbsp;&nbsp;
            <a href="https://www.facebook.com/sharer.php?u=".$url.'" target="_blank" class="facebook"><i class="fa fa-facebook"></i> <span>Share</span></a>
            <a href="https://plus.google.com/share?url=".$url."" target="_blank" class="gplus"><i class="fa fa-google-plus"></i> <span>+1</span></a>
            <a href="https://twitter.com/intent/tweet?text=".$title."&amp;url=".$url."&amp;via=YOUR_TWITTER_HANDLE_HERE" target="_blank" class="twitter"><i class="fa fa-twitter"></i> <span>Tweet</span></a>
            <a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=".$title."" target="_blank" class="linkedin"><i class="fa fa-linkedin"></i> <span>Share</span></a>
            <a href="whatsapp://send?text=".$title." '.$url.'" target="_blank" class="whatsapp"><i class="fa fa-whatsapp"></i> <span>Share</span></a>
        </div>';
        return $sharebuttons.$content;
    }


Related Posts:

  1. How to have a “clean” post content, for excerpt and social networks sharing
  2. Best practices for localizing WordPress content?
  3. if the post has content
  4. I want to have my custom field use HTML, how do I do that?
  5. What’s the Best Way to Structure a Multi-Content Blog?
  6. How to Handle Distributed Development Workflow
  7. How can I clear oEmbed caches for YouTube on posts as they are loaded
  8. Recommended Books on WordPress for Management and non-Developers?
  9. Total word count for posts by one author
  10. Split content into multiple columns using more tag?
  11. Get Content From Blog Page
  12. Show content after the first and second paragraph
  13. Host wp-content on other domain, much like a CDN
  14. WordPress REST API – JSON “Rendered” Content Incorrect
  15. How do I make certain areas editable?
  16. What server settings are required to import WordPress XML file
  17. append_content help
  18. How to limit post content and remove image caption from it
  19. Is there a way to trigger an automatic import of a WP backup on creation of a new WP multisite site?
  20. Site content not showing
  21. How to just show first line of content
  22. Hiding posts and pages in panel
  23. Take excerpt of the content of the post and send it as the title to create new post
  24. Convert all youtube link to embed
  25. Change Content for Specific Page
  26. wp_insert_post iframe missing
  27. Grabbing specific content
  28. Does is_user_logged_in() block search bots?
  29. Replace full content with an excerpt
  30. Output string using php printf
  31. content gets scrambled
  32. Conflicting post edit options under dashboard
  33. How to make search and replace in content through php
  34. Disable external (3rd party) CALL (images,fonts..) in Dashboard
  35. Retrieve a specific number of words from post_Content
  36. Get the content inside shortcode and apply external function to it?
  37. Can somebody tell me how I am supposed to be using blogs.dir for network / MU sites?
  38. Hide specific content from excerpts
  39. Is there a way to show only the text editor
  40. How to make author box like this & add after every post?
  41. Hardening wordpress: wp-content file permissions?
  42. Extract an embedded video from the content
  43. same wordpress, 2 domains
  44. Displaying latest Posts – fixed height – Excerpt vs. Content?
  45. How to retrieve text only from a post using WP CLI?
  46. Doctype printed on the page content
  47. Images are searched in the wrong path
  48. Main WordPress site with several flexible clones
  49. Post Format Default Content
  50. Export + Import = wrongly duplicated content
  51. Post titles below the post format content
  52. Show image on the left and content on the right using ul li
  53. What is the precendence of item types within WordPress
  54. the_excerpt() in content.php and get_template_part() in single.php
  55. Problem with content – not loading
  56. Content not shown on some older browsers and mobile devices (SGS3)
  57. the_content() returning null in one category only, even though there is content
  58. tabbed content box with different tabbed background images
  59. Excerpt vs content formatting woes
  60. Page content not visible in backend
  61. Body-only page for a 2-page form [closed]
  62. Changing theme removes page content in dashboard’s post main editor
  63. Divide post content in three columns
  64. Website showing random code like texts in a post after pasting from MS Word
  65. Simple Math Quiz or Captcha to hide whois query form
  66. highlight specific text in the content box
  67. qTranslate 2.5.28 and WordPress 3.3.1 issues [closed]
  68. How do i configure my content to show full posts?
  69. How to show content for posts of a specific category only
  70. What is the best practice to localize content? (Geographic not langauge)
  71. Duplicate content with incremental titles. How is this happening?
  72. How to create social Share Buttons Without Plugin
  73. Upgrading to WP 5+ with block content – Export & Import Page Content
  74. Images over HTTPS endless issues – mixed content
  75. How can I change page content for good once a button is pressed?
  76. Printing first line of content in wordpress
  77. Custom slugs for Each Tab
  78. Using Elementor to get dynamic content for wordpress on a predefined theme
  79. Content export, reinstall and content import
  80. mixed content missing from wordpress media
  81. Open content directory help!
  82. Need help with invisible content block
  83. Is it possible to remove the content editor (RTF field) for a certain user / role?
  84. How to get the list of posts with empty content
  85. preg_replace style attr in $content and Editing post_content before saving
  86. Retrieve content of page by URL Parameter
  87. The post content just showing up text
  88. I am not seeing any content within WordPress after migration?
  89. Need help for showing same front content page, search page and portfolio post page
  90. Add Flatr button to Sharing option
  91. Wp Some Pages content Not display in editor after move live server
  92. Put teaser content, more-link and full content in different divs if existing… Possible?
  93. Add video tag to youtube link fron content
  94. Having a strange wordpress issue where content does not load when past a certain amount
  95. How to embed PDF files inside content without media_send_to_editor?
  96. get_the_content within foreach not the loop
  97. Update content on the fly
  98. Visual Editor not working for user on multiple computers
  99. Migrate bbpress content to posts
  100. Where to place landing pages or files inside wordpress?
Categories content Tags buttons, content, social-sharing
Adding srcset to an image in ajax
Sending Email upon registration

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