Content MarketingSocial Media & Influencer Marketing

WordPress: Add Social Media Profiles to Your WordPress Theme

WordPress offers user profiles with settings for social links; however, additional social sites offer opportunities for your entire site or blog to have a presence within those networks. We were working on a client site this week where we wanted to make it easy for them to set and add their site’s social links, so we added additional options to their WordPress General Settings page.

Our first step was to update their Theme Functions (functions.php) in their Child Theme and register each of the settings we wished to add:

 // —————Add Settings to General Settings—————– 
 function social_settings_api_init() {
 	// Add the section to general settings so we can add our
 	// fields to it
 	add_settings_section('social_setting_section',
		'Social sites on the web',
		'social_setting_section_callback_function',
		'general');
 	
 	// Add the field with the names and function to use for our new
 	// settings, put it in our new section
 	add_settings_field('general_setting_facebook',
		'Facebook Page',
		'general_setting_facebook_callback_function',
		'general',
		'social_setting_section');
 	
 	// Register our setting so that $_POST handling is done for us and
 	// our callback function just has to echo the <input>
 	register_setting('general','general_setting_facebook');
 	
 	add_settings_field('general_setting_twitter',
		'Twitter Account',
		'general_setting_twitter_callback_function',
		'general',
		'social_setting_section');
 	register_setting('general','general_setting_twitter');
 	
 	add_settings_field('general_setting_youtube',
		'YouTube Page',
		'general_setting_youtube_callback_function',
		'general',
		'social_setting_section');
 	register_setting('general','general_setting_youtube');
 	
 	add_settings_field('general_setting_linkedin',
		'LinkedIn Page',
		'general_setting_linkedin_callback_function',
		'general',
		'social_setting_section');
 	register_setting('general','general_setting_linkedin');
 }
 add_action('admin_init', 'social_settings_api_init');

Our next step was to add the actual fields within the General Settings page that would save the information within them:

 // —————-Settings section callback function———————- 
 function social_setting_section_callback_function() {
 	echo '<p>This section is where you can save the social sites where readers can find you on the Internet.</p>';
 }	
 function general_setting_facebook_callback_function() {
 	echo '<input name="general_setting_facebook" id="general_setting_facebook" type="text" value="'. get_option('general_setting_facebook') .'" />';
 }
 function general_setting_twitter_callback_function() {
 	echo '<input name="general_setting_twitter" id="general_setting_twitter" type="text" value="'. get_option('general_setting_twitter') .'" />';
 }
 function general_setting_youtube_callback_function() {
 	echo '<input name="general_setting_youtube" id="general_setting_youtube" type="text" value="'. get_option('general_setting_youtube') .'" />';
 }
 function general_setting_linkedin_callback_function() {
 	echo '<input name="general_setting_linkedin" id="general_setting_linkedin" type="text" value="'. get_option('general_setting_linkedin') .'" />';
 }

Now, anytime the client wishes to update their social page settings, they can just update the settings fields within their WordPress General Settings. Within the theme, we simply recall the setting wherever needed (in this client’s case, it was a social media navigation bar in the heading of their site):

<?php echo get_option('general_setting_facebook'); >

Appreciate this content?

Sign up for our weekly newsletter, which delivers our latest posts every Monday morning.

We don’t spam! Read our privacy policy for more info.

Douglas Karr

Douglas Karr is a fractional Chief Marketing Officer specializing in SaaS and AI companies, where he helps scale marketing operations, drive demand generation, and implement AI-powered strategies. He is the founder and publisher of Martech Zone, a leading publication in marketing technology, and a trusted advisor to startups and enterprises alike. With a track record spanning more than $5 billion in MarTech acquisitions and investments, Douglas has led go-to-market strategy, brand positioning, and digital transformation initiatives for companies ranging from early-stage startups to global tech leaders like Dell, GoDaddy, Salesforce, Oracle, and Adobe. A published author of Corporate Blogging for Dummies and contributor to The Better Business Book, Douglas is also a recognized speaker, curriculum developer, and Forbes contributor. A U.S. Navy veteran, he combines strategic leadership with hands-on execution to help organizations achieve measurable growth.

Related Articles

Back to top button
Close

Adblock Detected

We rely on ads and sponsorships to keep Martech Zone free. Please consider disabling your ad blocker—or support us with an affordable, ad-free annual membership ($10 US):

Sign Up For An Annual Membership