Community Forums › Forums › Archived Forums › Design Tips and Tricks › Social Media Share Buttons Help
Tagged: css, functions.php, social media
- This topic has 4 replies, 2 voices, and was last updated 9 years, 6 months ago by itzsnider.
-
AuthorPosts
-
May 27, 2015 at 1:04 pm #153854itzsniderParticipant
All,
I am trying to add a set of my own buttons under the 1st paragraph in Parallax Pro.
I have accomplished it with a shortcode but can't figure out how to make it happen without crashing the site.
function ads_added_above_last_p($text) { if( is_single() ) : $ads_text = '<div class="a" style="text-align: center;">[PUT SHORTCODE HERE]</div>'; if($pos1 = strpos($text, '<p>', strpos($text, '<p>') + 3)){ $text1 = substr($text, 0, $pos1); $text2 = substr($text, $pos1); $text = $text1 . $ads_text . $text2; } endif; return $text; } add_filter('the_content', 'ads_added_above_last_p');
The above is the code to make it work - you can put anything, ads etc where it says [PUT SHORTCODE HERE]
BUT, what I want to do is add the following to the site now.
Here is the code I use in the widget now to show "after entry".
<div class="opt-social_vertical-column vertical-column-top"> <a class="opt-social_vertical-column_link facebook" href="https://www.facebook.com/sharer/sharer.php" onclick="var sharerFb = 'https://www.facebook.com/sharer/sharer.php?u='; window.open(sharerFb + location.href, 'sharerFb', 'width=626,height=436'); return false;">Share</a> <a class="opt-social_vertical-column_link twitter" href="https://twitter.com/share" onclick="var sharerTw = 'https://twitter.com/share?url='; window.open(sharerTw + location.href, 'sharerTw', 'width=550,height=520'); return false;">Tweet</a> </div>
When I replace <div class="a" style="text-align: center;">[PUT SHORTCODE HERE]</div> with the above, it crashes the functions.php.
What the heck am I missing here?
http://www.geekdaily.coMay 27, 2015 at 2:23 pm #153861Sridhar KatakamParticipantTry this:
function ads_added_above_last_p( $text ) { if( is_single() ) : $ads_text = '<div class="a" style="text-align: center;"><div class="opt-social_vertical-column vertical-column-top"> <a class="opt-social_vertical-column_link facebook" href="https://www.facebook.com/sharer/sharer.php" onclick="var sharerFb = \'https://www.facebook.com/sharer/sharer.php?u=\'; window.open(sharerFb + location.href, \'sharerFb\', \'width=626,height=436\'); return false;">Share</a> <a class="opt-social_vertical-column_link twitter" href="https://twitter.com/share" onclick="var sharerTw = \'https://twitter.com/share?url=\'; window.open(sharerTw + location.href, \'sharerTw\', \'width=550,height=520\'); return false;">Tweet</a> </div></div>'; if( $pos1 = strpos( $text, '<p>', strpos( $text, '<p>' ) + 3 ) ){ $text1 = substr( $text, 0, $pos1 ); $text2 = substr( $text, $pos1 ); $text = $text1 . $ads_text . $text2; } endif; return $text; } add_filter( 'the_content', 'ads_added_above_last_p' );
May 27, 2015 at 4:05 pm #153872itzsniderParticipantWhat am I missing?
I am trying to add the rest of the code -
<a class="opt-social_vertical-column_link google" href="https://plus.google.com/share" onclick="var sharerGp = 'https://plus.google.com/share?url='; window.open(sharerGp + location.href, 'sharerGp', 'width=840,height=464'); return false;">+1</a> <a class="opt-social_vertical-column_link reddit" href="http://www.reddit.com/submit" onclick="var sharerRd = 'http://www.reddit.com/submit?url='; window.open(sharerRd + location.href, 'sharerRd', 'width=840,height=464'); return false;">Submit</a>
May 28, 2015 at 6:44 am #153949itzsniderParticipantDid a html to php convertor and this is what I added
still crashes it!
<a class="opt-social_vertical-column_link google" href="https://plus.google.com/share" onclick="var sharerGp = \'https://plus.google.com/share?url=\'; window.open(sharerGp + location.href, \'sharerGp\', \'width=840,height=464\'); return false;">+1</a> <a class="opt-social_vertical-column_link reddit" href="http://www.reddit.com/submit" onclick="var sharerRd = \'http://www.reddit.com/submit?url=\'; window.open(sharerRd + location.href, \'sharerRd\', \'width=840,height=464\'); return false;">Submit</a>';
May 28, 2015 at 6:55 am #153950itzsniderParticipantGOT IT!
damn ;
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.