Skip to main content

How to create custom social share button in wordpress without plugin?

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

Popular posts from this blog

How to check date format in PHP?

Check date format in PHP function isCorrectDateFromat($date){     if(!empty($date)){         $dateString = $date; // Replace this with your date string         $format = "Y-m-d"; // Replace this with your expected date format         $dateTime = DateTime::createFromFormat($format, $dateString);         if ($dateTime === false) { /*             echo "The date is not in the correct format."; */         } else {             $errors = DateTime::getLastErrors();             if (empty($errors)) { /*                 echo "The date is in the correct format."; */                 return true;             } else { /*                 echo "...