-
AuthorPosts
-
September 14, 2014 at 12:35 pm #104600
Perfect, thank you very, very much! 🙂
September 14, 2014 at 12:36 pm #104601You’re Welcome Alexei.
Have a nice day, Cheers!
September 18, 2014 at 3:42 am #107054Hi I would like to have email as one of the social media icons; what do you recommend in order to achieve this.
Also is there a way of using “standard” social media icons (i.e colours)September 18, 2014 at 4:17 am #107068Hi there,
Please replace the code inside function.php with this ode:
<?php // ============================================================================= // FUNCTIONS.PHP // ----------------------------------------------------------------------------- // Overwrite or add your own custom functions to X in this file. // ============================================================================= 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; if ( true) : $output .= '<a href="' . $email . '" class="email" title="Email" target="_blank"><i class="x-icon-envelope"></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; } 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; } ); });
Hope it helps.
September 19, 2014 at 2:26 am #107813Didnt quite work but thanks for the starting point. I should be able to hack it from here.
cheers Peter
September 19, 2014 at 2:38 am #107817Hi Peter,
okay, have a great day!
September 20, 2014 at 9:03 pm #108952Hello,
I’m trying to add the social media share links to all of my blog posts as well but I don’t really understand how to start.
How to I create a content.php file in my Child Theme Editor? is there a link to a tutorial you can provide?
Thank you,
SSeptember 21, 2014 at 12:00 am #108997Hey Sarah,
Please give us the URL of your post and tell us where you want to put the sharing icons.
Thanks.
February 25, 2015 at 5:11 am #214784We would like to add the following to the bottom of every single blog post. Specifically, these are the shortcodes we would like to add to each single blog post created:
[share title=”Share this Post” facebook=”true” twitter=”true” google_plus=”true” linkedin=”true” pinterest=”true” reddit=”true” email=”true”]
[author title=”About the Author”]
Currently we can only work out how to do this with shortcodes in each post manually, but it is repeated information, so hoping we can resolve this by putting it in the theme for posts.
Your answers in this thread above are very specific to that person, but we would like to know how to do this as well. Assuming we have to use a Child Theme as described above so it is kept even when updated, but need specific instructions on how to do this.
We are using the Renew stack but have not implemented Child Themes yet.
February 25, 2015 at 7:26 am #214870OK…I thought we’d fixed it, but just testing on main site for now before moving this change to Child Themes and we changed content.php file as described in one of the posts in this thread and it breaks the posts.
The below is the entire “edited” content.php file.
We have changed no other files.
It is actually adding the things we want: Author and Social Share, but it’s stopping the actual post body text from appearing.
The other issue is that the Author and Social Share appears in the full Blog list (list with just excerpt and photos) as well. We just want these on each actual posts itself.
Please help.
<?php // ============================================================================= // VIEWS/RENEW/CONTENT.PHP // ----------------------------------------------------------------------------- // Standard post output for Renew. // ============================================================================= ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="entry-wrap"> <?php x_get_view( 'renew', '_content', 'post-header' ); ?> <?php if ( has_post_thumbnail() ) : ?> <div class="entry-featured"> <?php x_featured_image(); ?> </div> <?php endif; ?> <?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"]');?> <?php echo do_shortcode('[author title=”About the Author”]');?> </div> </article>
February 25, 2015 at 7:55 am #214880In the hope this helps out others, the answer in our situation was to change the code to the following in the file called wp-single.php (not content.php). We will move it to child themes now to resolve update issues.
<?php // ============================================================================= // VIEWS/RENEW/WP-SINGLE.PHP // ----------------------------------------------------------------------------- // Single post output for Renew. // ============================================================================= $fullwidth = get_post_meta( get_the_ID(), '_x_post_layout', true ); ?> <?php get_header(); ?> <div class="x-container max width offset"> <div class="<?php x_main_content_class(); ?>" role="main"> <?php while ( have_posts() ) : the_post(); ?> <?php x_get_view( 'renew', 'content', get_post_format() ); ?> <?php echo ('</br>'); ?> <?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"]');?> <?php echo do_shortcode('[author title=”About the Author”]');?> <?php x_get_view( 'global', '_comments-template' ); ?> <?php endwhile; ?> </div> <?php if ( $fullwidth != 'on' ) : ?> <?php get_sidebar(); ?> <?php endif; ?> </div> <?php get_footer(); ?>
February 25, 2015 at 9:01 am #214954Hi,
Thanks for the tips.
Glad you have figured it out.
Have a nice day!
-
AuthorPosts