Create custom social share button in wordpress without plugin.
function social_icons_products(){
global $wpdb;
global $post;
$full_line = get_permalink();
$slug = basename(get_permalink());
// $url = str_replace("/", "%2F", $full_line);
// $url = str_replace(":", "%3A", $url);
?>
<style>
.social_icons_container {
text-align: center;
align-items: center;
display: inline-flex;
margin: 0px !important;
}
.font_icons {
padding: 6px 13px 6px 13px;
cursor: pointer;
font-size: 15px;
color: black;
transition: 0.1s all ease-in-out;
}
.font_icons:hover {
background: black;
color: white;
}
.share_text {
margin-bottom: 1px;
font-size: 16px;
color: black;
margin-right: 10px;
}
</style>
<div class="social_icons_container">
<p class="share_text">Share</p>
<a href="<?php echo 'https://www.facebook.com/sharer/sharer.php?href='.$full_line; ?>" >
<div class="font_icons"><i class="fab fa-facebook-f"></i>
</div>
</a>
<a href="<?php echo 'https://twitter.com/intent/tweet?url='.$full_line.'"' ?>" >
<div class="font_icons"><i class="fab fa-twitter"></i>
</div>
</a>
<a href="<?php echo 'https://www.linkedin.com/shareArticle?mini=true&url='.$full_line.'"' ?>" >
<div class="font_icons"><i class="fab fa-linkedin-in"></i>
</div>
</a>
</div>
<?php
}
add_action('woocommerce_share','social_icons_products');
Comments
Post a Comment