Grow your CSS skills. Land your dream job.

share buttons and wordpress

  • jmc
    # May 10, 2012 at 3:32 pm

    I am in the process of establishing my first wordpress theme, and within the post loop, I would like to add some share buttons. I am not entirely certain if this can be achieved, but is there a way to, instead of putting in a static URL for the button (ex. facebook like button), put a line of php that dynamically places the URL of the post the buttons are nested in?

    I was looking into the Share This plugin, but I’m unsure if this would be a viable solution for me.

    any help would be greatly appreciated!

    # May 10, 2012 at 3:42 pm

    Yes sir, most certainly is possible although I’m not sure if it’s compatible with the Share This link you shared. It looks like their code doesn’t have a spot for the URL. Their code grabs it for you.

    However, if you do find a code where you type in the url it’s very easily done.

    First you grab whatever the current URL is and create a variable:

    < ?php $url = $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; ?>

    and then you add it where a social media code needs it (the following example is a Facebook Comments code):

    jmc
    # May 10, 2012 at 3:58 pm

    the only question I have now is where exactly would I place the first line of code?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".