• I’m creating a custom theme and I would like to add share links to individual posts.

    First, when building a custom theme is it better to just use a plugin for this or build it into the php file?

    If the php file is a viable option, how do you go about creating these links? I think I was doing it correctly for Twitter, but when I tried the same for Facebook it was asking for a url, which I do not have yet because I’m doing this locally at the moment.

    I want to do this for Linkedin, Facebook, Twitter and also link that opens an email populating the post.

    Any information or direction would be greatly appreciated!

    This is the page I was starting to use, but I wanted to ask before I got too far. The Twitter instructions allow you to get your button, but Facebook was asking for a url which surprised me because I through the url would be dynamic depending on the post

    https://blog.hubspot.com/blog/tabid/6307/bid/29544/the-ultimate-cheat-sheet-for-creating-social-media-buttons.aspx

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator t-p

    (@t-p)

    Thread Starter lgehrig4

    (@lgehrig4)

    Thank you. I actually came across this before. By posting it as your reply are you inferring that that is the only way to do it or the best way? I ask because I’m trying to get as much experience building the site in php, but if this is the way to go then so be it.

    Moderator bcworkz

    (@bcworkz)

    There are several possible ways. t-p’s suggestion is probably best for WP beginners. You may not learn much by using an existing plugin, though you can always study its source code to get a grasp on how things are done.

    You could place the necessary code on your theme template files, but that kind of locks you into that particular theme, which is fine for many people. If implemented as a plugin, you are able to change themes at will without impacting your code. However, getting plugin code output to appear where you like on a page gets a bit more involved. Depending on where that is, there could be a useful filter or action hook to use so you can maintain portability of your code.

    If you want to develop your own code for the learning experience, I think it’s a great way to learn. One challenge you’ll face is the APIs for various social sites are all going to be different. To interact with each site’s API, you’ll likely need separate, dedicated code for each. However there could be certain common elements, so that modularizing your code could save you from some redundancy.

    Thread Starter lgehrig4

    (@lgehrig4)

    This!

    If you want to develop your own code for the learning experience, I think it’s a great way to learn. One challenge you’ll face is the APIs for various social sites are all going to be different. To interact with each site’s API, you’ll likely need separate, dedicated code for each. However there could be certain common elements, so that modularizing your code could save you from some redundancy

    The purpose of what I am doing is to learn while creating this theme. Can you point me to good resources on how to start this?

    Is this a good reference?

    https://developer.wordpress.com/docs/api/1/get/meta/sharing-buttons/

    Thread Starter lgehrig4

    (@lgehrig4)

    Disregard that link I posted above. Didn’t realize it was wordpress.com

    Thread Starter lgehrig4

    (@lgehrig4)

    Found this and wanted to post for anyone else looking to do the same

    https://daan.dev/wordpress/social-share-buttons-php/

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding share link button in Invividual post’ is closed to new replies.