Skip to content

Instantly share code, notes, and snippets.

@thecodepoetry
Last active October 9, 2020 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thecodepoetry/d67c058ebf899a7e6afd12d925f01740 to your computer and use it in GitHub Desktop.
Save thecodepoetry/d67c058ebf899a7e6afd12d925f01740 to your computer and use it in GitHub Desktop.
Share buttons shortcode
function share_func( $atts ){
$share_buttons = the7_get_share_buttons_list( 'post');
if ( apply_filters( 'presscore_hide_share_buttons', empty( $share_buttons ) ) ) {
return;
}
if ( 'on_hover' === of_get_option( 'social_buttons-visibility' ) ) {
$wrap_class .= ' show-on-hover';
}
$share_buttons_header = the7_get_share_buttons_header( 'post' );
$share ='';
$share .= '<div class="single-share-box '.esc_attr( $wrap_class ).'">';
$share .= '<div class="share-link-description">'.esc_html( $share_buttons_header ).'</div>';
$share .= '<div class="share-buttons">';
foreach ( $share_buttons as $share_button ) {
$share .= '<a class="'.esc_attr( $share_button["icon_class"] ).'" href="'.esc_url( $share_button["url"] ).'" title="'.esc_attr( $share_button["name"] ).'" target="_blank" '.$share_button["custom_atts"].'><span class="soc-font-icon"></span><span class="social-text">'.esc_html( $share_button["alt_title"] ).'</span><span class="screen-reader-text">'.esc_html( $share_button["title"] ).'</span></a>';
}
$share .= '</div></div>';
return $share;
}
add_shortcode( 'sharebuttons', 'share_func' );
@thecodepoetry
Copy link
Author

Please try this code in your child theme fucntions.php

Then add [sharebuttons] shortcode to the editor

Also add below custom CSS to to Theme options > Advacned > Custom CSS section

#content > .single-share-box {
	display: none;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment