-
AuthorPosts
-
September 13, 2014 at 4:01 am #104056
Hello again 🙂
I would like to see social sharing buttons on all of my posts.
I’ve added this code (found in the forum) to my child theme’s functions.php:
add_filter('the_content', function($content){ return $content.'[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true"]'; });
After refreshing, got a 500 error.
I also have this code in there:
function x_social_global() { $facebook = x_get_option( 'x_social_facebook' ); $twitter = x_get_option( 'x_social_twitter' ); $google_plus = x_get_option( 'x_social_googleplus' ); $linkedin = x_get_option( 'x_social_linkedin' ); $foursquare = x_get_option( 'x_social_foursquare' ); $youtube = x_get_option( 'x_social_youtube' ); $vimeo = x_get_option( 'x_social_vimeo' ); $instagram = x_get_option( 'x_social_instagram' ); $pinterest = x_get_option( 'x_social_pinterest' ); $dribbble = x_get_option( 'x_social_dribbble' ); $behance = x_get_option( 'x_social_behance' ); $tumblr = x_get_option( 'x_social_tumblr' ); $rss = x_get_option( 'x_social_rss' ); $output = '<div class="x-social-global">'; if ( $facebook ) : $output .= '<a href="' . $facebook . '" class="facebook" title="Facebook" target="_blank"><i class="x-social-facebook"></i></a>'; endif; if ( $twitter ) : $output .= '<a href="' . $twitter . '" class="twitter" title="Twitter" target="_blank"><i class="x-social-twitter"></i></a>'; endif; if ( $google_plus ) : $output .= '<a href="' . $google_plus . '" class="google-plus" title="Google+" target="_blank"><i class="x-social-google-plus"></i></a>'; endif; if ( $linkedin ) : $output .= '<a href="' . $linkedin . '" class="linkedin" title="LinkedIn" target="_blank"><i class="x-social-linkedin"></i></a>'; endif; if ( $foursquare ) : $output .= '<a href="' . $foursquare . '" class="foursquare" title="Foursquare" target="_blank"><i class="x-social-foursquare"></i></a>'; endif; if ( $youtube ) : $output .= '<a href="' . $youtube . '" class="youtube" title="YouTube" target="_blank"><i class="x-social-youtube"></i></a>'; endif; if ( $vimeo ) : $output .= '<a href="' . $vimeo . '" class="vimeo" title="Vimeo" target="_blank"><i class="x-social-vimeo"></i></a>'; endif; if ( $instagram ) : $output .= '<a href="' . $instagram . '" class="instagram" title="Instagram" target="_blank"><i class="x-social-instagram"></i></a>'; endif; if ( $pinterest ) : $output .= '<a href="' . $pinterest . '" class="pinterest" title="Pinterest" target="_blank"><i class="x-social-pinterest"></i></a>'; endif; if ( $dribbble ) : $output .= '<a href="' . $dribbble . '" class="dribbble" title="Dribbble" target="_blank"><i class="x-social-dribbble"></i></a>'; endif; if ( $behance ) : $output .= '<a href="' . $behance . '" class="behance" title="Behance" target="_blank"><i class="x-social-behance"></i></a>'; endif; if ( $tumblr ) : $output .= '<a href="' . $tumblr . '" class="tumblr" title="Tumblr" target="_blank"><i class="x-social-tumblr"></i></a>'; endif; if ( $rss ) : $output .= '<a href="' . $rss . '" class="rss" title="RSS" target="_blank"><i class="x-social-rss"></i></a>'; endif; $output .= '<a style="position: relative;top: -2px;" href="http://vk.com/bhumibrushes" class="vk" title="VK" target="_blank"><i class="x-icon-vk"></i></a></div>'; echo $output; }
Must be doing something wrong, can you please help me fix it?
Thank you! 🙂
September 13, 2014 at 5:31 am #104067Hi there,
Please delete the code above and copy _content-post-header.php from
YOUR THEME -> Framework -> Views -> {STACK NAME}And make this path in child theme:
YOUR CHILD THEME -> Framework -> Views -> {STACK NAME}
Now past _content-post-header.php in there , Open the file and add this code before </header>
<?php echo do_shortcode('[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true"]') ; ?>
Hope it helps.
September 13, 2014 at 5:52 am #104074Thanks! Did you mean delete the code I’ve found in the forum or all of the code above? I have deleted the forum code already, what I have in there now is the code that adds VK social network (the second piece of code above). And I would like to have VK as one of the sharing buttons. So how do I go about that? Sorry, I’m clueless 🙂
September 13, 2014 at 5:57 am #104075P.S. I have VK as one of the social media in the footer and would also like to have a share button for it, to be clear.
Thanks!
September 13, 2014 at 8:22 am #104108Hi there,
Just add this code in same path instead of last suggested one:
<?php echo do_shortcode('[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true" rss="true"]') ; ?> <a href="PUT VK URL HERE"><i class="x-icon-vk"></i></a>
Let me know if it works.
September 13, 2014 at 10:59 am #104157Thanks!
Here’s what I got https://www.dropbox.com/s/6lype2uk0pn4uxr/PostScreen.bmp?dl=0
And would it be possible to have the buttons below posts?
Thank you 🙂
September 13, 2014 at 11:04 am #104164P.S. And do they have to show up on the preview page?
September 13, 2014 at 11:59 am #104185Hi there,
If you wish to set them after the content then copy content.php from YOUR THEME -> Framework -> Views -> {STACK NAME} and put it same path in your child theme ,Open file and and put the code below just before last </div>.
<div class="custom-social"> <?php echo do_shortcode('[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true" rss="true"]') ; ?> <a href="#"><i class="x-icon-vk"></i></a> </div>
Also if you want to delete the social from blog page add Customize -> Custom -> CSS
.blog .custom-social { display: none; }
Thank you.
September 13, 2014 at 1:03 pm #104207Thanks, the buttons are still above the content. And the VK button is still below the buttons, on the left right above the content, just like on the screenshot I sent.
Thank you!
September 13, 2014 at 3:12 pm #104248Hi Alexei,
Change the given code to this :
<div class="custom-social"> <?php echo do_shortcode('[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true" rss="true"]') ; ?> </div>
Then add this code at your child theme’s functions.php
add_action('wp_head', function(){ remove_shortcode( 'share' ); add_shortcode( 'share', function ( $atts ) { extract( shortcode_atts( array( 'id' => '', 'class' => '', 'style' => '', 'title' => '', 'facebook' => '', 'twitter' => '', 'google_plus' => '', 'linkedin' => '', 'pinterest' => '', 'reddit' => '', 'email' => '' ), $atts ) ); $share_url = urlencode( get_permalink() ); $share_title = urlencode( get_the_title() ); $share_source = urlencode( get_bloginfo( 'name' ) ); $share_content = urlencode( get_the_excerpt() ); $share_media_info = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' ); $share_media = $share_media_info[0]; $id = ( $id != '' ) ? 'id="' . esc_attr( $id ) . '"' : ''; $class = ( $class != '' ) ? 'x-entry-share ' . esc_attr( $class ) : 'x-entry-share'; $style = ( $style != '' ) ? 'style="' . $style . '"' : ''; $title = ( $title != '' ) ? $title : __( 'Share this Post', '__x__' ); $facebook = ( $facebook == 'true' ) ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __( 'Share on Facebook', '__x__' ) . "\" onclick=\"window.open('http://www.facebook.com/sharer.php?u={$share_url}&t={$share_title}', 'popupFacebook', 'width=650, height=270, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-social-facebook\"></i></a>" : ''; $twitter = ( $twitter == 'true' ) ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __( 'Share on Twitter', '__x__' ) . "\" onclick=\"window.open('https://twitter.com/intent/tweet?text={$share_title}&url={$share_url}', 'popupTwitter', 'width=500, height=370, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-social-twitter\"></i></a>" : ''; $google_plus = ( $google_plus == 'true' ) ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __( 'Share on Google+', '__x__' ) . "\" onclick=\"window.open('https://plus.google.com/share?url={$share_url}', 'popupGooglePlus', 'width=650, height=226, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-social-google-plus\"></i></a>" : ''; $linkedin = ( $linkedin == 'true' ) ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __( 'Share on LinkedIn', '__x__' ) . "\" onclick=\"window.open('http://www.linkedin.com/shareArticle?mini=true&url={$share_url}&title={$share_title}&summary={$share_content}&source={$share_source}', 'popupLinkedIn', 'width=610, height=480, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-social-linkedin\"></i></a>" : ''; $pinterest = ( $pinterest == 'true' ) ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __( 'Share on Pinterest', '__x__' ) . "\" onclick=\"window.open('http://pinterest.com/pin/create/button/?url={$share_url}&media={$share_media}&description={$share_title}', 'popupPinterest', 'width=750, height=265, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-social-pinterest\"></i></a>" : ''; $reddit = ( $reddit == 'true' ) ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __( 'Share on Reddit', '__x__' ) . "\" onclick=\"window.open('http://www.reddit.com/submit?url={$share_url}', 'popupReddit', 'width=875, height=450, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-social-reddit\"></i></a>" : ''; $email = ( $email == 'true' ) ? "<a href=\"mailto:?subject=" . get_the_title() . "&body=" . __( 'Hey, thought you might enjoy this! Check it out when you have a chance:', '__x__' ) . " " . get_permalink() . "\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share email\" title=\"" . __( 'Share via Email', '__x__' ) . "\"><span><i class=\"x-icon-envelope\"></i></span></a>" : ''; $vk = "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __( 'Share on VK', '__x__' ) . "\" ><i class=\"x-icon-vk\"></i></a>"; $output = "<div {$id} class=\"{$class}\" {$style}>" . '<p>' . $title . '</p>' . '<div class="x-share-options">' . $facebook . $twitter . $google_plus . $linkedin . $pinterest . $reddit . $email . $vk . '</div>' . '</div>'; return $output; } ); });
Cheers!
September 13, 2014 at 3:30 pm #104259Hello again,
This is what I’m getting https://www.dropbox.com/s/scjltk4yc24pa7o/PostScreen2.bmp?dl=0
Cheers!
September 13, 2014 at 5:02 pm #104295BTW, if it helps at all… if you do a search, in the results two sets of buttons come up – above and below.
Thanks!
September 13, 2014 at 5:03 pm #104296Hi there,
As recommended, please change the given code like this :
<div class="custom-social"> <?php echo do_shortcode('[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true" rss="true"]') ; ?> <a href="#"><i class="x-icon-vk"></i></a> </div>
into this :
<div class="custom-social"> <?php echo do_shortcode('[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true" rss="true"]') ; ?> </div>
Thanks.
September 13, 2014 at 5:19 pm #104306Thanks, I did already, that’s what you gave me the last time. It added VK to the the buttons but neither moved them below the post, nor removed that extra VK icon right above the post.
Thank you!
September 13, 2014 at 5:23 pm #104307Here’s the full contents of my content.php
<?php // ============================================================================= // VIEWS/INTEGRITY/CONTENT.PHP // ----------------------------------------------------------------------------- // Standard post output for Integrity. // ============================================================================= ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="entry-featured"> <?php x_featured_image(); ?> </div> <div class="entry-wrap"> <?php x_get_view( 'integrity', '_content', 'post-header' ); ?> <?php x_get_view( 'global', '_content' ); ?> <div class="custom-social"> <?php echo do_shortcode('[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true" rss="true"]') ; ?> </div> </div> <?php x_get_view( 'integrity', '_content', 'post-footer' ); ?> <?php x_google_authorship_meta(); ?> </article>
And here’s the _content-post-header.php
<?php // ============================================================================= // VIEWS/INTEGRITY/_CONTENT-POST-HEADER.PHP // ----------------------------------------------------------------------------- // Standard <header> output for various posts. // ============================================================================= ?> <header class="entry-header"> <?php if ( is_single() ) : ?> <h1 class="entry-title"><?php the_title(); ?></h1> <?php else : ?> <h2 class="entry-title"> <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php x_the_alternate_title(); ?></a> </h2> <?php endif; ?> <?php x_integrity_entry_meta(); ?> <?php echo do_shortcode('[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true" rss="true"]') ; ?> <a href="PUT VK URL HERE"><i class="x-icon-vk"></i></a> </header>
Am I doing something wrong?
-
AuthorPosts