Let face it you can get any functionality done with WordPress plugins. however, sometimes it’s better not to install too many plugins on your website which can sometimes lead to a plugin conflict.
Although, in this blog post, we will be learning how to create social media widget without a plugin for our theme. Nonetheless, this could be achieved using a plugin but will not be going through that route.
Let get started we will be working in our functions.php file however, you can create a separate file and put all your codes into it and include it in your functions.php just to make things easy to read. Also you will need to create a custom style for your widget and ensure font-awesome is added to your website to get the right look and feel.
//create a class extending the WP_Widget of WordPress
class Media_Social_Profile extends WP_Widget {
}
Let Register our Social Media Widget
// The code below should be in class created above
/**
* Register widget with WordPress.
*/
function __construct() {
parent::__construct(
‘Media_Social_Profile’,
__(‘Social Networks Profile’, ‘text-domain’),
// Name
array(‘description’ => __(‘Links to Author social media profile’, ‘text-domain’),)
);
}
The code below displays our widget in the front end of our website.