How To Change Social Icons Order

Molongui » Help » Molongui Authorship Docs » Howto » How To Change Social Icons Order

In the author box, icons are displayed in alphabetical order, so a social network which name starts with an “A” gets its icon displayed before any other network. Facebook icon appears before Twitter’s, for instance.

You might want to change that to give more importance to some networks listing them first. Whatever the reason, you can define the order in which to display the icons adding the following code to your functions.php file.

				
					 /**
  * Order social media icons.
  *
  * Molongui Authorship Plugin.
  * https://wordpress.org/plugins/molongui-authorship/
  *
  * @param array $nouse Empty array. No use.
  * @param array $networks Unsorted array of current active networks.
  * @return array Sorted array of active networks.
  */
  function order_authorship_social_icons( $nouse, $networks )
  {
    // Here you can handle $networks array to order it as you wish. 
    // Sort in alphabetical order: sort( $networks );
    // or sort in reverse alphabetical order: rsort( $networks ); 
    // or randomize the order: shuffle( $networks );
    // or provide a custom order indicating social network ids: $networks = array( 'youtube', 'amazon', 'facebook', 'twitter', 'instagram' );
    
    // And always return the array.
    return $networks;
    }
    add_filter( 'authorship/social_networks/order', 'order_authorship_social_icons', 10, 2 );
				
			

If you want to indicate a given order, you need to provide an array of social network IDs. The ID for a social network is, usually, the lowercase version with spaces removed of its name. So for “Facebook”, the id is “facebook”. And for “Read the Docs” it is “readthedocs”. You can get to know the ID of each social network in this support article that lists all available networks.

Updated on February 21, 2022

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