No results found. Try again with different words?

Search must be at least 3 characters.

Customizing Social Profile Links for Individual Authors in Single Posts

Sidebar Image

Did not find a solution? We are here to help you succeed.

Astra’s customizer option (Customizer > Blog > Single Post > Author Info) allows setting a single social URL for authors. While this works well for single author websites, it presents a challenge in multi-author scenarios, as the set URL applies to all authors, regardless of who wrote the content.

To address this limitation and enable individualized author profiles, a specific code snippet can be implemented. This document provides detailed instructions on using the snippet to assign unique social links to each author.

Customize Social Profile Links for Individual Authors in Single Posts

Using the below-attached simple code snippet, you can unlock author-specific social links, allowing you to showcase each writer’s unique social profile links alongside their work.

You can add the below provided code to your child theme’s functions.php file

add_filter( 'astra_addon_author_social_sharing_link', 'update_author_wise_social_links', 10, 2 );

function update_author_wise_social_links( $social_link, $network ) {

	global $post;
	$post_author_id = ! empty( $post->post_author ) ? absint( $post->post_author ) : 1;

	switch ( $network ) {
		case 'facebook':
			if ( 43 === $post_author_id ) {
				$social_link = 'https://www.facebook.com/astra-team'; // For author user id 43
			} elseif ( 4 === $post_author_id ) {
				$social_link = 'https://www.facebook.com/admin'; // For author user id 4
			} else {
				$social_link = 'https://www.facebook.com/brainstormforce'; // Fallback facebook social link
			}
			break;

		case 'twitter':
			$social_link = 'https://twitter.com/bsfwp';
			break;

		case 'linkedin':
			$social_link = 'https://www.linkedin.com/company/brainstorm-force/';
			break;

		case 'youtube':
			$social_link = 'https://www.youtube.com/channel/UCP6LzCTEr7ZKTuWzc9ZxVqw';
			break;

		default:
			// Do nothing or extend this case as per other social networks.
			break;
	}

	return $social_link;
}

You can update the example social links with the actual URLs of your authors and adjust the author IDs to match your specific users.

In this example, the snippet differentiates Facebook links based on the author, providing unique Social links for each author, thus overcoming the issue of uniform Social links for multiple authors.

We hope this document has been helpful. If you have any queries further, feel free to leave a comment below.

Was this article helpful?
Sidebar Image

Did not find a solution? We are here to help you succeed.

Related Docs

Join 1,653,898+ Happy Site Owners Using Astra

Whether you are a beginner, small business owner, or professional web developer, Astra provides all the tools you need to easily build your beautiful WordPress website.

Download is Just A Click Away!

Membership Retention Checklist Download

REWIND

YEAR IN REVIEW

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

Download Free Astra Theme - Modal Popup Form
Scroll to Top
Now choose your preferred
page builder addon
Choose your preferred page builder addon

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

Download Free Astra Theme - Modal Popup Form