How can I add a new social network beyond those supported natively to a listing?

You are here:
  • KB Home
  • Custom Fields
  • How can I add a new social network beyond those supported natively to a listing?
< Back

Here is an example of doing so for Vkontakte (this code should be placed in your theme’s functions.php file):

add_filter('drts_social_medias', function($medias) {
    $medias['vkontakte'] = [
        'type' => 'textfield',
        'label' => 'VKontakte',
        'icon' => 'fab fa-vk',
        'default' => 'vkontakte',
        'placeholder' => 'Enter VKontakte username.',
    ];
    return $medias;
});
add_filter('drts_social_media_url', function($url, $name, $value) {
    if ($name === 'vkontakte') {
        $url = 'https://vk.com/' . $value;
    }
    return $url;
}, 10, 3);
Tags: