Aggiungere i Social Network al profilo utente di WordPress, è una piccola ebreve guida su come inserire correttamente, rispettando la sintassi di WordPress, i Social Network.
1. La funzione in functions.php
Nel file functions.php aggiungi la funzione sottostante:
function add_contact_profile($user_contact) { $user_contact['twitter'] = __('URL Twitter'); $user_contact['facebook'] = __('URL Facebook'); $user_contact['googleplus'] = __('URL Google Plus'); $user_contact['linkedin'] = __('URL Linkedin'); return $user_contact; } add_filter('user_contactmethods', 'add_contact_profile');
In sintesi con questa funzione aggiungi (nell’array “user_contactmethods”) dei nuovi campi; puoi mettere tutti i campi che desideri, rispettando la sintassi che ti ho mostrato.
Aggiungere i Social Network al profilo utente di WordPress
Adesso vai nella tua Amministrazione di WordPress e, nella sezione Utenti -> Il tuo profilo, vedrai che nella sezione Informazione Contatti ci saranno i nuovi campi, che potrai riempire come desideri.
2. Far apparire i Social Network
A questo punto devi mostrare i Social Network, è sufficente che apri un file come (header.php, single.php, index.php, footer.php, ecc. ecc.) ed inserire un codice simile a quello qui sotto:
$user_id = get_current_user_id(); if(get_the_author_meta('googleplus', $user_id) ){ echo('<a href="'. get_the_author_meta('googleplus', $user_id) .'" target="_blank"> <i class="fa fa-google-plus"></i> </a>'); } if(get_the_author_meta('facebook', $user_id) ){ echo('<a href="'. get_the_author_meta('facebook', $user_id) .'" target="_blank"> <i class="fa fa-facebook"></i> </a>'); } if(get_the_author_meta('twitter', $user_id) ){ echo('<a href="'. get_the_author_meta('twitter', $user_id) .'" target="_blank"> <i class="fa fa-twitter"></i> </a>'); } if(get_the_author_meta('linkedin', $user_id) ){ echo('<a href="'. get_the_author_meta('linkedin', $user_id) .'" target="_blank"> <i class="fa fa-linkedin"></i> </a>'); }
Se ti è interessato, Aggiungere i Social Network al profilo utente di WordPress, allora potrebbe anche piacerti: Aggiungere commenti di facebook a pagine di wordpress