Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#1 2017-02-07 07:05:08

michilge
Member
From: Sprockhövel, Germany
Registered: 2013-04-15
Posts: 206
Website

Quick and easy: social media sharing links for Backlight WP Theme

In another thread I asked if it were possible to display the author and creation date in a blog post.

Rod and Matthew pointed me to creating a Wordpress child theme.
Thanks again for the help.
I now enhanced my child theme with social media sharing links that help my visitors share a link to the post in Facebook an Twitter.

This is all that I had to put into my child themes content.php (the file content.php is a modified copy of the original in the parent theme and the taxonomies-section is retyped only to identify the place where I inserted the new code):

<?php 
...					
// Taxonomies 
	echo '<p class="taxonomies">';
	the_category(' '); 
	the_tags(' ',' ',' '); 
	echo '</p>';
				
// Social Media sharing links 
	$connectURL = 'https://api-ssl.bit.ly/v3/shorten?login=my_bitly_username&apiKey=my_bitly_ApiKey&longUrl='.urlencode(get_permalink()).'&format=txt';
	$bitly = file_get_contents($connectURL);
?>
<p>
	Share with friends:
	<a target= "_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>" title="Facebook"><i class="fa fa-fw fa-facebook"></i><span>Share</span></a>
	<a target= "_blank" href="https://twitter.com/intent/tweet?text=Found at @kannznichkaufen: <?php echo $bitly; ?>" title="Twittern!"><i class="fa fa-fw fa-twitter"></i><span>Tweet!</span></a>
</p>
...

Of course the Twitter and Bit.ly usernames and key must be edited.

Feedback and ideas on improvement are welcome.
I post this in the support section rather than in Tips&Tricks because there might be negative implications I did not see yet.

Michael

Last edited by michilge (2017-02-07 16:15:33)

Offline

#2 2017-02-07 07:17:35

Daniel Leu
Moderator
Registered: 2012-10-11
Posts: 1,624
Website

Re: Quick and easy: social media sharing links for Backlight WP Theme

Thank you for sharing! The Twitter link works for me, but not Facebook. This is the generated link:

https://fotos.michilge.de/blog/westfalenpokal-fc-bruenninghausen-tsg-sprockhoevel-12/%20title=

I think the href argument is missing a closing quote:

<a target= "_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>" title="Facebook"><i class="fa fa-fw fa-facebook"></i><span>Share</span></a>

Daniel Leu | Photography   
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com

Offline

#3 2017-02-07 07:33:16

michilge
Member
From: Sprockhövel, Germany
Registered: 2013-04-15
Posts: 206
Website

Re: Quick and easy: social media sharing links for Backlight WP Theme

Edit:

Ah got it. I hope it's better now.
Can You please check it once again.
I don't even have a FB account myself, so I did not see the mistake first.

Thank You.
Michael

Last edited by michilge (2017-02-07 07:39:50)

Offline

#4 2017-02-07 10:35:45

Daniel Leu
Moderator
Registered: 2012-10-11
Posts: 1,624
Website

Re: Quick and easy: social media sharing links for Backlight WP Theme

Now it works :-)


Daniel Leu | Photography   
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com

Offline

#5 2017-02-07 16:17:31

michilge
Member
From: Sprockhövel, Germany
Registered: 2013-04-15
Posts: 206
Website

Re: Quick and easy: social media sharing links for Backlight WP Theme

Thank you.
Code in first post has been corrected.

Offline

Board footer

Powered by FluxBB